Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            mus = new MyUserSettings();

            numericX.Value = mus.secondX;
            numericY.Value = mus.secondY;

            keyboardHookManager.Start();
            keyboardHookManager.RegisterHotkey(NonInvasiveKeyboardHookLibrary.ModifierKeys.Alt, 0x60, () =>
            {
                Debug.WriteLine("Alt+NumPad0 detected");


                //click screen
                SimMouse.Click(MouseButtons.Left, (int)numericX.Value, (int)numericY.Value);  //right minus
                Thread.Sleep(100);

                //get active app handle
                IntPtr handle1 = GetForegroundWindow();

                //move app
                ShowWindow(handle1, 1);
                MoveWindow(handle1, 200, 200, 500, 500, true);


                //-------------------------------------

                //click screen
                SimMouse.Click(MouseButtons.Left, 1780, 0); //left minus
                Thread.Sleep(100);

                //get active app handle
                IntPtr handle2 = GetForegroundWindow();

                //move app
                ShowWindow(handle2, 1);
                MoveWindow(handle2, 2120, 363, 500, 500, true);


                ShowWindowAsync(handle1, 3);
                ShowWindowAsync(handle2, 3);


                /*
                 * // left to right
                 * SimMouse.Click(MouseButtons.Left, 1780, 0);
                 * Thread.Sleep(1000);
                 * SimMouse.Act(SimMouse.Action.LeftButtonDown, 1780, 0);
                 * Thread.Sleep(1000);
                 * SimMouse.Act(SimMouse.Action.LeftButtonUp, 1780, 200);
                 * Thread.Sleep(1000);
                 * SimMouse.Act(SimMouse.Action.LeftButtonDown, 1780, 200);
                 * Thread.Sleep(1000);
                 * SimMouse.Act(SimMouse.Action.LeftButtonUp, 2780, 200);
                 * Thread.Sleep(1000);
                 * SimMouse.Click(MouseButtons.Left, 3057, 163);
                 * Thread.Sleep(1000);
                 *
                 * //right to left
                 * SimMouse.Act(SimMouse.Action.LeftButtonDown, 3057, 163);
                 * Thread.Sleep(100);
                 * SimMouse.Act(SimMouse.Action.LeftButtonUp, 3057, 363);
                 * Thread.Sleep(100);
                 * SimMouse.Act(SimMouse.Action.LeftButtonDown, 3057, 363);
                 * Thread.Sleep(100);
                 * SimMouse.Act(SimMouse.Action.LeftButtonUp, 1780, 363);
                 */
            });
            notifyIcon1.Visible = true;
            timer1.Stop();
            this.Hide();
        }
Пример #2
0
 public void LeftClick(int x, int y, int delay)
 {
     SimMouse.Click(MouseButtons.Left, x, y);
     System.Threading.Thread.Sleep(delay);
 }