Exemple #1
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);
        }
Exemple #2
0
        public void SendWindowOnTop()
        {
            // 抓取雷電模擬器的Handle
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);

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

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


            WinApi.SetForegroundWindow(test);
        }
Exemple #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 Image GetImage(CaptureMode captureMode)
        {
            IntPtr intPtr = WinApi.FindWindow(null, this.Name);
            Image  image  = null;

            if (captureMode == CaptureMode.DirectX)
            {
                image = Direct3DCapture.CaptureWindow(intPtr);
            }
            else
            {
                if (captureMode != CaptureMode.Gdi)
                {
                    throw new NotImplementedException("尚未實作的擷取畫面模式");
                }
                image = (new ScreenCapture()).CaptureWindow(intPtr);
            }
            return(image);
        }
Exemple #5
0
        public Image GetImage(CaptureMode captureMode)
        {
            // 抓取雷電模擬器的Handle
            IntPtr handle = WinApi.FindWindow(null, Name);
            Image  image  = null;

            switch (captureMode)
            {
            case CaptureMode.DirectX:
                //dmsoft dm = new dmsoft();
                //dm.cap
                image = Direct3DCapture.CaptureWindow(handle);
                break;

            case CaptureMode.Gdi:
                ScreenCapture sc = new ScreenCapture();
                image = sc.CaptureWindow(handle);
                break;

            default:
                throw new NotImplementedException("尚未實作的擷取畫面模式");
            }
            return(image);
        }
Exemple #6
0
        public void SendMessage(string action)
        {
            // 抓取雷電模擬器的Handle
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);

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

            if (Name.Contains("雷電"))
            {
                test = WinApi.FindWindowEx(hwndCalc, 0, null, null);
            }
            else
            {
                test = hwndCalc;
            }

            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);
            }
        }
Exemple #7
0
        public bool IsSimulatorOpen()
        {
            IntPtr hwndCalc = WinApi.FindWindow(null, Name);

            return(hwndCalc != IntPtr.Zero);
        }
        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);
            }
        }
 public bool IsSimulatorOpen()
 {
     return(WinApi.FindWindow(null, this.Name) != IntPtr.Zero);
 }