Example #1
0
        public void SendMessage(string action)
        {
            // 抓取雷電模擬器的Handle
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);

            string[] hotkeyList = HotKeyList.Split(',');
            IntPtr   test       = IntPtr.Zero;

            test = WinApi.FindWindowEx(hwndCalc, 0, null, null);

            if (action == hotkeyList[0])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.D7), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.D7), 0);
            }
            else if (action == hotkeyList[1])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.D8), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.D8), 0);
            }
            else if (action == hotkeyList[2])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.D9), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.D9), 0);
            }
            else if (action == hotkeyList[3])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.D0), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.D0), 0);
            }
            else if (action == hotkeyList[4])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.U), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.U), 0);
            }
            else if (action == hotkeyList[5])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.I), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.I), 0);
            }
            else if (action == hotkeyList[6])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.O), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.O), 0);
            }
            else if (action == hotkeyList[7])
            {
                WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.P), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.P), 0);
            }
        }
Example #2
0
        public void SendAutoAttackMessage()
        {
            // 抓取雷電模擬器的Handle
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);
            IntPtr test     = IntPtr.Zero;

            test = WinApi.FindWindowEx(hwndCalc, 0, null, null);


            WinApi.SendMessage(test, WM_KEYDOWN, Convert.ToInt32(Keys.K), 0);
            Thread.Sleep(100);
            WinApi.SendMessage(test, WM_KEYUP, Convert.ToInt32(Keys.K), 0);
        }
Example #3
0
        public void SendMouseMessage(int x, int y)
        {
            // 抓取雷電模擬器的Handle
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);
            IntPtr test     = IntPtr.Zero;

            test = WinApi.FindWindowEx(hwndCalc, 0, null, null);


            WinApi.SendMessage(test, WM_LBUTTONDOWN, 0, x + (y << 16));
            Thread.Sleep(100);
            WinApi.SendMessage(test, WM_LBUTTONUP, 0, x + (y << 16));
            Thread.Sleep(100);
            WinApi.SendMessage(test, WM_LBUTTONDOWN, 0, x + (y << 16));
            Thread.Sleep(100);
            WinApi.SendMessage(test, WM_LBUTTONUP, 0, x + (y << 16));
        }
        public void SendMessage(string action)
        {
            IntPtr intPtr = WinApi.FindWindow(null, this.Name);

            string[] strArrays = SimulatorInfo.HotKeyList.Split(new char[] { ',' });
            IntPtr   zero      = IntPtr.Zero;

            zero = (!this.Name.Contains("雷電") ? intPtr : WinApi.FindWindowEx(intPtr, 0, null, null));
            if (action == strArrays[0])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.D7), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.D7), 0);
                return;
            }
            if (action == strArrays[1])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.D8), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.D8), 0);
                return;
            }
            if (action == strArrays[2])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.D9), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.D9), 0);
                return;
            }
            if (action == strArrays[3])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.D0), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.D0), 0);
                return;
            }
            if (action == strArrays[4])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.U), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.U), 0);
                return;
            }
            if (action == strArrays[5])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.I), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.I), 0);
                return;
            }
            if (action == strArrays[6])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.O), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.O), 0);
                return;
            }
            if (action == strArrays[7])
            {
                WinApi.SendMessage(zero, this.WM_KEYDOWN, Convert.ToInt32(Keys.P), 0);
                Thread.Sleep(100);
                WinApi.SendMessage(zero, this.WM_KEYUP, Convert.ToInt32(Keys.P), 0);
            }
        }