Example #1
0
        private void hook_KeyDown(object sender, KeyEventArgs e)
        {
            int buttonKey = (int)e.KeyCode;

            if (buttonKey == (int)Keys.Oem3) //截获~
            {
                runFlag = (!runFlag);
                this.ChangeStatus(runFlag);
                if (runFlag)
                {
                    timer1.Start();
                    //timer2.Start();
                    //timer3.Start();
                    //timer4.Start();
                    //timerR.Start();
                    //timerL.Start();
                }
                else
                {
                    keybd_event(Keys.LMenu, 0, KEYEVENTF_KEYUP, 0);
                    timer1.Stop();
                    //timer2.Stop();
                    //timer3.Stop();
                    //timer4.Stop();
                    //timerR.Stop();
                    //timerL.Stop();
                }
                return;
            }
            else if (buttonKey == (int)Keys.D1)
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    if (runFlag)
                    {
                        keybd_event(Keys.LShiftKey, 0, 0, 0);
                        MouseHook.MouseLeftClickEvent(0);
                        keybd_event(Keys.LShiftKey, 0, KEYEVENTF_KEYUP, 0);
                    }
                }
            }
            else if (buttonKey == (int)Keys.NumPad1)
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    for (int i = 0; i < 30; i++)
                    {
                        Thread.Sleep(10);
                        MouseHook.MouseRightClickEvent(0);
                    }
                }
            }
        }
Example #2
0
        private void timerR_Tick(object sender, EventArgs e)
        {
            IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
            IntPtr activeWindow = GetForegroundWindow();

            if (activeWindow == hwnd)
            {
                MouseHook.MouseRightClickEvent(0);
            }
        }
Example #3
0
        private void timerR_Tick(object sender, EventArgs e)
        {
            IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
            IntPtr activeWindow = GetForegroundWindow();

            if (activeWindow == hwnd)
            {
                if (runFlag)
                {
                    MouseHook.MouseRightClickEvent(0);
                }
            }
            else
            {
                runFlag = false;
                this.ChangeStatus(runFlag);
            }
        }
Example #4
0
        /// <summary>
        /// 鼠标
        /// </summary>
        /// <param name = "sender" ></ param >
        /// < param name="e"></param>
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            MouseKeyHook hook = (MouseKeyHook)sender;

            if (e.Button == MouseButtons.Middle) //鼠标中键--买装备
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    Task task1 = new Task(() =>
                    {
                        for (int i = 0; i < 30; i++)
                        {
                            Thread.Sleep(20);
                            MouseHook.MouseRightClickEvent(0);
                        }
                    });
                    task1.Start();
                }
            }
        }
 private void timerR_Tick(object sender, EventArgs e)
 {
     //
     MouseHook.MouseRightClickEvent(0);
 }