Пример #1
0
        private void timerR_Tick(object sender, EventArgs e)
        {
            IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
            IntPtr activeWindow = GetForegroundWindow();

            if (activeWindow == hwnd)
            {
                MouseHook.MouseRightClickEvent(0);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        private void timerL_Tick(object sender, EventArgs e)
        {
            //
            IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
            IntPtr activeWindow = GetForegroundWindow();

            if (activeWindow == hwnd)
            {
                if (runFlag)
                {
                    keybd_event(Keys.LMenu, 0, 0, 0);
                    MouseHook.MouseLeftClickEvent(0);
                    keybd_event(Keys.LMenu, 0, KEYEVENTF_KEYUP, 0);
                }
            }
            else
            {
                runFlag = false;
                this.ChangeStatus(runFlag);
            }
        }
Пример #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();
                }
            }
        }
Пример #5
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
                {
                    //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 == false)
                    {
                        runFlag = true;
                        timerR.Start();
                        timerL.Start();
                        this.ChangeStatus(runFlag);
                        //keybd_event(Keys.LMenu, 0, 0, 0);
                        //MouseHook.MouseLeftClickEvent(0);
                        //keybd_event(Keys.LMenu, 0, KEYEVENTF_KEYUP, 0);
                    }
                }
            }
            else if (buttonKey == (int)Keys.D2)
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    if (runFlag)
                    {
                        SendKeys.Send("{4}");
                    }
                }
            }
            else if (buttonKey == (int)Keys.Escape || buttonKey == (int)Keys.Tab)
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    if (runFlag)
                    {
                        runFlag = (!runFlag);
                        this.ChangeStatus(runFlag);
                    }
                }
            }
            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);
                    }
                }
            }
        }
Пример #6
0
 private void timerR_Tick(object sender, EventArgs e)
 {
     //
     MouseHook.MouseRightClickEvent(0);
 }