public void SetHook()
        {
            lock (lockObject)
            {
                if (IsActivated)
                {
                    throw new InvalidOperationException();
                }
                var log = new CallLogger("SetWindowsHookEx");
                log.Add("Hook type: {0}", Enum.GetName(typeof(HookType), hookType));
                var hInstance = GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName);

                log.Add("hInstance: 0x{0:X}", hInstance.ToInt64());
                hHook = SetWindowsHookEx((int)hookType, systemCallback, hInstance, 0);
                if (IsActivated)
                {
                    log.Add("hHook: 0x{0:X}", hHook.ToInt64());
                    log.Success();
                }
                else
                {
                    log.FailWithErrorCode();
                }
            }
        }
示例#2
0
        private void btnStatus_Click(object sender, EventArgs e)
        {
            switch (PhoneStatus)
            {
            case PhoneStatus.Ringing:
            {
                PickupPhone();
                break;
            }


            case PhoneStatus.Talking:
            {
                HangupPhone();
                break;
            }

            case PhoneStatus.ReadyHuman:
            {
                btnStatus.Text      = "Talking (Hang Up)";
                btnStatus.BackColor = Color.PowderBlue;
                PhoneStatus         = PhoneStatus.Talking;
                CallLogger.LogInteraction(InteractionWho.Phone, InteractionWhat.Pickup, SystemColors.Desktop, "");
                currentPhoneNum = outgoingPhoneNumber;
                SystemController.Instance.Office.PhoneDialingIn(Settings.Default.DefaultFromNumber, outgoingPhoneNumber);
                break;
            }
            }
        }
示例#3
0
 private void PickupPhone()
 {
     btnStatus.Text      = "Talking (Hang Up)";
     btnStatus.BackColor = Color.PowderBlue;
     PhoneStatus         = PhoneStatus.Talking;
     CallLogger.LogInteraction(InteractionWho.Phone, InteractionWhat.Pickup, SystemColors.Desktop, "");
     SystemController.Instance.Office.PhonePickedUp(currentPhoneNum, DefaultPhoneStatus == PhoneStatus.ReadyMachine?true:false);
 }
示例#4
0
        private void SubmitBuffer()
        {
            CallLogger.LogInteraction(InteractionWho.Phone, InteractionWhat.Say, SystemColors.Desktop, lblBuffer.Text.Replace("Buffer: ", ""));
            tmrDial.Enabled = false;

            SystemController.Instance.Office.PhoneSendingDigits(PhoneNumber, lblBuffer.Text.Replace("Buffer: ", ""));
            lblBuffer.Text    = "";
            lblBuffer.Visible = false;
        }
示例#5
0
        public void Intro()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <CallLogger>();
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                CallLogger callLogger = scope.Resolve <CallLogger>();
                TestUtilities.WriteLine(callLogger);
                TestUtilities.Attach();
            }
        }
示例#6
0
        protected void Send(INPUT[] input)
        {
            var log = new CallLogger("SendInput");

            foreach (var item in input.Select((v, i) => new { v, i }))
            {
                var inputType = (InputType)item.v.type;
                if (inputType.Equals(InputType.INPUT_MOUSE))
                {
                    var data      = item.v.data.asMouseInput;
                    var eventType = (MouseEventType)data.dwFlags;

                    log.Add("MouseEvent[{0}]:", item.i);
                    log.Add("dx: {0}", data.dx);
                    log.Add("dy: {0}", data.dy);
                    log.Add("dwFlags: {0} | {1}", eventType, ToHexString(data.dwFlags));
                    if (eventType.HasFlag(MouseEventType.MOUSEEVENTF_XDOWN | MouseEventType.MOUSEEVENTF_XUP))
                    {
                        log.Add("mouseData: {0} | {1}", (XButtonType)data.mouseData.asXButton.type, ToHexString((uint)data.mouseData.asXButton.type));
                    }
                    else if (eventType.HasFlag(MouseEventType.MOUSEEVENTF_WHEEL | MouseEventType.MOUSEEVENTF_HWHEEL))
                    {
                        log.Add("mouseData: {0} | {1}", data.mouseData.asWheelDelta.delta, ToHexString((uint)data.mouseData.asWheelDelta.delta));
                    }
                    log.Add("dwExtraInfo: {0}", ToHexString(data.dwExtraInfo.ToUInt64()));
                }
                else if (inputType.HasFlag(InputType.INPUT_KEYBOARD))
                {
                    var data      = item.v.data.asKeyboardInput;
                    var eventType = (KeyboardEventType)data.dwFlags;
                    log.Add("KeyboardEvent[{0}]:", item.i);
                    log.Add("wVk: {0}", data.wVk);
                    log.Add("wScan: {0}", data.wScan);
                    log.Add("dwFlags: {0} | {1}", eventType, ToHexString(data.dwFlags));
                    log.Add("dwExtraInfo: {0}", ToHexString(data.dwExtraInfo.ToUInt64()));
                }
            }
            if (SendInput((uint)input.Length, input, Marshal.SizeOf(input[0])) > 0)
            {
                log.Success();
            }
            else
            {
                log.FailWithErrorCode();
            }
        }
示例#7
0
        public void RegisterTypeThrowsException()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <CallLogger>()
            .As <ILogger>()
            .As <ICallInterceptor>();
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                // This WON'T WORK anymore because we specified
                // service overrides on the component:
                CallLogger callLogger = scope.Resolve <CallLogger>();
                TestUtilities.WriteLine(callLogger);
                TestUtilities.Attach();
            }
        }
示例#8
0
        /// <summary>
        /// http://autofac.readthedocs.io/en/latest/register/registration.html#services-vs-components
        /// If you want to expose a component as a set of services as well as
        /// using the default service, use the AsSelf method:
        /// </summary>
        private static void AsSelfSample()
        {
            Console.WriteLine("\nAsSelfSample:\n");
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <CallLogger>()
            .AsSelf()
            .As <ILogger>()
            .As <ICallInterceptor>();
            IContainer container = builder.Build();

            using (ILifetimeScope lifetimeScope = container.BeginLifetimeScope())
            {
                ILogger logger = lifetimeScope.Resolve <ILogger>();
                Console.WriteLine("ILogger resolved");
                ICallInterceptor icaCallInterceptor = lifetimeScope.Resolve <ICallInterceptor>();
                Console.WriteLine("ICallInterceptor resolved");
                CallLogger callLogger = lifetimeScope.Resolve <CallLogger>();
                Console.WriteLine("CallLogger resolved");
            }
        }
 public void Unhook()
 {
     lock (lockObject)
     {
         if (!IsActivated)
         {
             throw new InvalidOperationException();
         }
         var log = new CallLogger("UnhookWindowsHookEx");
         log.Add("Hook type: {0}", Enum.GetName(typeof(HookType), hookType));
         log.Add("hHook: 0x{0:X}", hHook);
         if (UnhookWindowsHookEx(hHook))
         {
             log.Success();
         }
         else
         {
             log.FailWithErrorCode();
         }
         hHook = IntPtr.Zero;
     }
 }
示例#10
0
        public void AsSelf()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <CallLogger>()
            .AsSelf()
            .As <ILogger>()
            .As <ICallInterceptor>();
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                // These will all work because we exposed
                // the appropriate services in the registration:
                ILogger          iLogger         = scope.Resolve <ILogger>();
                ICallInterceptor callInterceptor = scope.Resolve <ICallInterceptor>();
                CallLogger       callLogger      = scope.Resolve <CallLogger>();
                TestUtilities.WriteLine(iLogger);
                TestUtilities.WriteLine(callInterceptor);
                TestUtilities.WriteLine(callLogger);
                TestUtilities.Attach();
            }
        }
示例#11
0
 private void HangupPhone()
 {
     PhoneStatus = DefaultPhoneStatus;
     SystemController.Instance.Office.PhoneHungUp(outgoingPhoneNumber);
     CallLogger.LogInteraction(InteractionWho.Phone, InteractionWhat.Hangup, SystemColors.Desktop, "");
 }
示例#12
0
        public void Run()
        {
            Task.Factory.StartNew(() =>
            {
                foreach (var x in ParsedScripts)
                {
                    DateTime?WaitUntil = null;

                    if (ShouldCancel)
                    {
                        return;
                    }
                    if (x.Command.ToUpper() == "DIGITS")
                    {
                        SystemController.Instance.Office.PhoneSendingDigits(PhoneNumber, x.Text.Trim());
                        CallLogger.LogDigitPressed(x.Text);
                    }
                    if (ShouldCancel)
                    {
                        return;
                    }
                    if (x.Command.ToUpper() == "WAIT")
                    {
                        WaitUntil = DateTime.Now.AddSeconds(int.Parse(x.Text));
                    }


                    while (true)
                    {
                        if (ShouldCancel)
                        {
                            return;
                        }

                        switch (x.Command.ToUpper())
                        {
                        case "WAIT":
                            {
                                if (DateTime.Now > WaitUntil)
                                {
                                    goto OutOfLoop;
                                }
                                break;
                            }

                        case "WAITFOR":
                            {
                                if (x.Text.Trim().StartsWith("}") && x.Text.Trim().EndsWith("}"))
                                {
                                    if (Regex.IsMatch(buffer, x.Text.Trim(), RegexOptions.Singleline))
                                    {
                                        buffer = "";
                                        goto OutOfLoop;
                                    }
                                }
                                else
                                {
                                    if (buffer.ToUpper().Contains(x.Text.Trim().ToUpper()))
                                    {
                                        buffer = "";
                                        goto OutOfLoop;
                                    }
                                }
                                break;
                            }

                        default:
                            {
                                goto OutOfLoop;
                            }
                        }


                        Thread.Sleep(1000);
                    }
                    ;

                    OutOfLoop:;

                    if (ShouldCancel)
                    {
                        return;
                    }
                }
                ;
            }, TaskCreationOptions.LongRunning);
            ShouldCancel = false;
        }
示例#13
0
 public void SayReceived(string PhoneNumber, string Text)
 {
     CallLogger.LogTwilioSay(Text);
     buffer += " " + Text;
 }