Пример #1
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.Left && hook.WParam == 0x201) //左键down
            {
                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.LShiftKey, 0, KEYEVENTF_KEYUP, 0);
                    }
                }
            }
            else if (e.Button == MouseButtons.Left && hook.WParam == 0x202) //左键up
            {
                IntPtr hwnd         = FindWindow(null, toolStripTextBoxWinName.Text);
                IntPtr activeWindow = GetForegroundWindow();
                if (activeWindow == hwnd)
                {
                    if (runFlag)
                    {
                        keybd_event(Keys.LMenu, 0, KEYEVENTF_KEYUP, 0);
                    }
                }
            }
        }
Пример #2
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();
                }
            }
        }