Esempio n. 1
0
        private void btnRecord_Click(object sender, RoutedEventArgs e)
        {
            SelectChangedSource = UiSelectChangedSource.SelectChangeFinished;

            if (IsRecording == false)
            {
                MouseKeyboardEventHandler.Init();

                btnRecord.Content            = "Pause";
                textBoxRecording.Text        = "Recording";
                gridTextRecording.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0));

                IsRecording = true;
                AppInsights.LogEvent("Record");
            }
            else
            {
                IsRecording = false;

                MouseKeyboardEventHandler.UnInit();

                btnRecord.Content            = "Record";
                textBoxRecording.Text        = "";
                gridTextRecording.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));

                AddInspectUi(null); // remove last Inspect node
                AppInsights.LogEvent("Pause");
            }
        }
Esempio n. 2
0
        public static IntPtr KeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0 || MouseKeyboardEventHandler.s_threadRecorder == null || MainWindow.s_mainWin.IsRecording == false)
            {
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            KeyboardEvents  kEvent = (KeyboardEvents)wParam.ToInt32();
            KBDLLHOOKSTRUCT kbd    = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            int         scanCode = (int)kbd.scanCode;
            VirtualKeys vk       = (VirtualKeys)kbd.vkCode;

            if (vk == VirtualKeys.VK_PAUSE && kEvent == KeyboardEvents.KeyDown)
            {
                s_bPauseMouseKeyboard = !s_bPauseMouseKeyboard;

                if (s_bPauseMouseKeyboard == true)
                {
                    NativeMethods.PostMessage(MainWindow.s_windowHandle, (int)MainWindow.UiThreadTask.PauseRecording, 0, 0);
                }
                else
                {
                    NativeMethods.PostMessage(MainWindow.s_windowHandle, (int)MainWindow.UiThreadTask.Active, 0, 0);
                }
            }

            if (s_bPauseMouseKeyboard == false)
            {
                MouseKeyboardEventHandler.RecordKey(kEvent, vk, scanCode);
            }

            return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Esempio n. 3
0
        public static IntPtr KeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            KeyboardEvents  kEvent = (KeyboardEvents)wParam.ToInt32();
            KBDLLHOOKSTRUCT kbd    = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            int         scanCode = (int)kbd.scanCode;
            VirtualKeys vk       = (VirtualKeys)kbd.vkCode;

            if (vk == VirtualKeys.VK_PAUSE && kEvent == KeyboardEvents.KeyDown)
            {
                s_bPausing = !s_bPausing;
            }

            // Record encoded key virtual key
            if (s_bPausing == false)
            {
                MouseKeyboardEventHandler.RecordKey(kEvent, vk, scanCode);
            }

            return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Esempio n. 4
0
        private void Window_Closed(object sender, EventArgs e)
        {
            MouseKeyboardEventHandler.UnInit();
            MouseKeyboardHook.StopHook();

            System.Windows.Interop.HwndSource.FromHwnd(windowHandle).RemoveHook(XmlNodePathRecorder.ProcessMessage);
            s_mainWin = null;
        }
Esempio n. 5
0
        private void Window_Closed(object sender, EventArgs e)
        {
            MouseKeyboardEventHandler.UnInit();
            MouseKeyboardHook.StopHook();
            s_mainWin = null;

            System.Windows.Interop.HwndSource.FromHwnd(s_windowHandle).RemoveHook(RunOnUiThread);

            AppInsights.LogEvent("Window_Closed");
        }
Esempio n. 6
0
        private void InitMouseKeyboard(Object source, System.Timers.ElapsedEventArgs e)
        {
            timer.Stop();
            timer.Elapsed -= InitMouseKeyboard;
            timer          = null;

            this.Dispatcher.Invoke(new Action(() =>
            {
                MouseKeyboardEventHandler.Init();
            }), System.Windows.Threading.DispatcherPriority.Normal);
        }
Esempio n. 7
0
        public static IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0 || MouseKeyboardEventHandler.s_threadRecorder == null || s_bPauseMouseKeyboard == true)
            {
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            MSLLHOOKSTRUCT mhs  = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            int            left = mhs.pt.X;
            int            top  = mhs.pt.Y;

            //skip if cursor is on this app
            IntPtr hwnd = NativeMethods.WindowFromPoint(left, top);

            if (hwnd == MainWindow.s_windowHandle)
            {
                MouseKeyboardEventHandler.ResetRecordTimer();
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            switch (wParam.ToInt32())
            {
            case WM_MOUSEMOVE:
                MouseKeyboardEventHandler.MouseMove(left, top);
                break;

            case WM_MOUSEWHEEL:
                short zDelta = (short)(mhs.mouseData >> 16);
                MouseKeyboardEventHandler.MouseWheel(left, top, zDelta);
                break;

            case WM_LBUTTONDOWN:
                MouseKeyboardEventHandler.LeftMouseDown(left, top);
                break;

            case WM_LBUTTONUP:
                MouseKeyboardEventHandler.LeftMouseUp(left, top);
                break;

            case WM_RBUTTONDOWN:
                MouseKeyboardEventHandler.RightMouseDown(left, top);
                break;

            case WM_RBUTTONUP:
                MouseKeyboardEventHandler.RightMouseUp(left, top);
                break;
            }

            return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Esempio n. 8
0
        private void btnRecord_Click(object sender, RoutedEventArgs e)
        {
            SelectChangedSource = UiSelectChangedSource.SelectChangeFinished;

            if (IsRecording == false)
            {
                try
                {
                    //Start Application Under Test
                    var app = new Winium.Cruciatus.Application(txtAppAddress.Text);
                    app.Start();

                    //******

                    MouseKeyboardEventHandler.Init();

                    btnRecord.Content            = "Pause";
                    textBoxRecording.Text        = "Recording";
                    gridTextRecording.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0));

                    IsRecording = true;
                    AppInsights.LogEvent("Record");
                }
                catch (Exception)
                {
                    MessageBox.Show("The application under test does not exists");
                }
            }
            else
            {
                IsRecording = false;

                MouseKeyboardEventHandler.UnInit();

                btnRecord.Content            = "Start";
                textBoxRecording.Text        = "";
                gridTextRecording.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));

                AddInspectUi(null); // remove last Inspect node
                AppInsights.LogEvent("Pause");
            }
        }