private void buttonClickRightOnImage_Click(object sender, EventArgs e)
        {
            AutoIT au3  = new AutoIT();
            IntPtr hWnd = IntPtr.Zero;

            // Find define handle of project
            hWnd = AutoControl.FindWindowHandle(null, textBoxTestID.Text);

            if (hWnd == IntPtr.Zero)
            {
                MessageBox.Show("Không tìm thấy nhân vật này đang được chạy.");
                return;
            }

            var imagePath = textBoxTestPath.Text;

            var screen = CaptureHelper.CaptureWindow(hWnd);

            screen.Save("test.png");
            Bitmap iBtn = ImageScanOpenCV.GetImage(imagePath);
            var    pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)screen, iBtn);

            if (pBtn != null)
            {
                au3.clickRight(textBoxTestID.Text, 1, pBtn.Value.X + int.Parse(numericUpDownTestX.Value.ToString()), pBtn.Value.Y + int.Parse(numericUpDownTestY.Value.ToString()));
                Thread.Sleep(Constant.TimeShort);
            }
        }
Exemple #2
0
        public List <Bitmap> collectMapMiniPath()
        {
            mAuto.writeStatus("Thu thập mảnh bản đồ");
            List <Bitmap> mapPaths = new List <Bitmap>();

            // Mở bảng đồ mini
            //mAuto.clickToImage(Constant.ImagePathMiniMap);
            mAuto.sendKey("~");

            var full_screen = CaptureHelper.CaptureWindow(mHWnd);

            // Tắt các bảng nổi
            mAuto.closeAllDialog();

            Bitmap iBtn = ImageScanOpenCV.GetImage(Constant.ImagePathGlobalMiniMap);
            var    pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)full_screen, iBtn);

            if (pBtn != null)
            {
                int x_start_point = pBtn.Value.X + 0;
                int y_start_point = pBtn.Value.Y + 60;
                for (int y = 0; y < 5; y++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        mapPaths.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(
                                                                 x_start_point + (x * 100),
                                                                 y_start_point + (y * 56),
                                                                 100, 56)));
                    }
                }
            }

            return(mapPaths);
        }
        // Start the CaptureHelper client using the required elements
        private async Task <long> StartCaptureClient()
        {
            int  Retries = 0;
            long result;

            Capture = new CaptureHelper();

#if DEBUG
            Capture.DebugConsole = new DebugConsole();
#endif
            Capture.DoNotUseWebSocket = true;
            Capture.DeviceArrival    += OnDeviceArrival;
            Capture.DeviceRemoval    += OnDeviceRemoval;
            Capture.DecodedData      += OnDecodedData;

            while ((result = await OpenCapture()) == SktErrors.ESKT_UNABLEOPENDEVICE)
            {
                Retries++;
                if (Retries == 60)
                {
                    break;
                }
                await Task.Delay(500);
            }

            // Report the result
            Android.Widget.Toast.MakeText(this, "StartCaptureClient result is: " + result + " Retries: " + Retries, Android.Widget.ToastLength.Short).Show();
            return(result);
        }
        /*
         * Function: isMoving
         * Description: Kiểm tra nhân vật đang di chuyển
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-10 - Updated At: 2019-11-10
         */
        public bool isMoving()
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            int  i      = 0;
            bool moving = true;

            while (moving && i < Constant.MaxLoop && mCharacter.Running != 0)
            {
                // Chụp màn hình
                var screen_first = CaptureHelper.CaptureWindow(mHWnd);
                screen_first = CaptureHelper.CropImage((Bitmap)screen_first, new Rectangle(180, 0, 250, 250));

                // Chờ 3s
                Thread.Sleep(1500);
                var screen_second = CaptureHelper.CaptureWindow(mHWnd);

                // Kiểm tra hình trước có trong hình sau hay không
                var p = ImageScanOpenCV.FindOutPoint((Bitmap)screen_second, (Bitmap)screen_first);
                if (p != null)
                {
                    moving = false;
                    return(moving);
                }
            }

            return(moving);
        }
Exemple #5
0
 private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e)
 {
     BeginInvoke((MethodInvoker) delegate
     {
         CaptureHelper.CaptureClipboard();
     });
 }
        public static void saveImage(int x, int y, int width, int height)
        {
            var scene = CaptureHelper.CaptureWindow(Global.mainHandle);

            scene = CaptureHelper.CropImage(scene, new System.Drawing.Rectangle(x, y, width, height));
            scene.Save("./img/debug/saveImage.png");
        }
Exemple #7
0
 private void Contextmenu_capturelastregionClick(object sender, EventArgs e)
 {
     BeginInvoke((MethodInvoker) delegate
     {
         CaptureHelper.CaptureLastRegion(false);
     });
 }
        private AutomationElement CaptureListView(AutomationElement openBatchWindow, ref Bitmap bmp)
        {
            var lstView = openBatchWindow.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, ""));

            bmp = CaptureHelper.CaptureControl((IntPtr)lstView.Current.NativeWindowHandle);
            return(lstView);
        }
Exemple #9
0
        public MainApplication(ProcessDetection processDetection, List <ClientMap> clientMapList, Settings appSettings)
        {
            this.AppSettings = appSettings;
            InitializeBackgroundWorker();
            this.processDetection = processDetection;
            this.ClientMapping    = clientMapList.AsEnumerable();

            IEnumerable <MonitorInfo> monitors = MonitorEnumerationHelper.GetMonitors();
            IEnumerable <MonitorInfo> primMons = from primaryMonitor in monitors
                                                 where primaryMonitor.IsPrimary == true
                                                 select primaryMonitor;
            MonitorInfo         monitor = primMons.FirstOrDefault();
            GraphicsCaptureItem item    = CaptureHelper.CreateItemForMonitor(monitor.Hmon);


            switch (Settings.AppRunMode)
            {
            case SettingsAppRunMode.MockGame:
                this.mockImage = new Mat(Settings.MockImageGame);
                break;

            case SettingsAppRunMode.MockLauncher:
                this.mockImage = new Mat(Settings.MockImageLauncher);
                break;
            }

            if (item != null)
            {
                this.StartCaptureFromItem(item);
            }
        }
Exemple #10
0
 private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e)
 {
     BeginInvoke((MethodInvoker) delegate
     {
         CaptureHelper.CaptureFullscreen(false, conf.ScreenCaptureMode);
     });
 }
Exemple #11
0
        /// <summary>
        ///     Handle the notify icon click
        /// </summary>
        private void NotifyIconClick(ClickActions clickAction)
        {
            switch (clickAction)
            {
            case ClickActions.OPEN_LAST_IN_EXPLORER:
                Contextmenu_OpenRecent(this, null);
                break;

            case ClickActions.OPEN_LAST_IN_EDITOR:
                _coreConfiguration.ValidateAndCorrect();

                if (File.Exists(_coreConfiguration.OutputFileAsFullpath))
                {
                    CaptureHelper.CaptureFile(_coreConfiguration.OutputFileAsFullpath, _destinationHolder.SortedActiveDestinations.Find("Editor"));
                }
                break;

            case ClickActions.OPEN_SETTINGS:
                ShowSetting();
                break;

            case ClickActions.SHOW_CONTEXT_MENU:
                var oMethodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
                oMethodInfo?.Invoke(notifyIcon, null);
                break;
            }
        }
Exemple #12
0
 private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e)
 {
     BeginInvoke((MethodInvoker) delegate
     {
         CaptureHelper.CaptureRegion(false);
     });
 }
Exemple #13
0
        private void Contextmenu_captureiefromlist_Click(object sender, EventArgs e)
        {
            if (!_coreConfiguration.IECapture)
            {
                Log.Info().WriteLine("IE Capture is disabled.");
                return;
            }
            var clickedItem = (ToolStripMenuItem)sender;
            var tabData     = (KeyValuePair <IInteropWindow, int>)clickedItem.Tag;

            BeginInvoke((MethodInvoker) delegate
            {
                var ieWindowToCapture = tabData.Key;
                if (ieWindowToCapture != null && ieWindowToCapture.IsMinimized())
                {
                    ieWindowToCapture.Restore();
                }
                try
                {
                    IeCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
                }
                catch (Exception exception)
                {
                    Log.Error().WriteLine(exception);
                }
                try
                {
                    CaptureHelper.CaptureIe(false, ieWindowToCapture);
                }
                catch (Exception exception)
                {
                    Log.Error().WriteLine(exception);
                }
            });
        }
Exemple #14
0
 private void CaptureIE()
 {
     if (_coreConfiguration.IECapture)
     {
         CaptureHelper.CaptureIe(true, null);
     }
 }
Exemple #15
0
        private void Contextmenu_captureIE_Click(object sender, EventArgs e)
        {
            if (!conf.IECapture)
            {
                LOG.InfoFormat("IE Capture is disabled.");
                return;
            }
            ToolStripMenuItem clickedItem             = (ToolStripMenuItem)sender;
            KeyValuePair <WindowDetails, int> tabData = (KeyValuePair <WindowDetails, int>)clickedItem.Tag;

            BeginInvoke((MethodInvoker) delegate
            {
                try
                {
                    IECaptureHelper.ActivateIETab(tabData.Key, tabData.Value);
                }
                catch (Exception exception)
                {
                    LOG.Error(exception);
                }
                try
                {
                    CaptureHelper.CaptureIE(false);
                }
                catch (Exception exception)
                {
                    LOG.Error(exception);
                }
            });
        }
Exemple #16
0
        public void LoginTranS()
        {
            string strCmdText;
            string userName = Environment.UserName;

            strCmdText = @"/C C:\Users\" + userName + @"\AppData\Roaming\TranS\TranS.exe";

            Process p = new Process();

            p.StartInfo.FileName  = "CMD.exe";
            p.StartInfo.Arguments = strCmdText;

            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            p.Start();
            Thread.Sleep(4000);

            //click Student
            var screen = CaptureHelper.CaptureScreen();

            screen.Save("mainScreen.png");
            var subBitmap = ImageScanOpenCV.GetImage("btnHocVien.bmp");
            var resBitmap = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBitmap);

            if (resBitmap != null)
            {
                string x = (resBitmap.ToString()).Remove(0, 3).Remove(3, 7);
                string y = (resBitmap.ToString()).Remove(0, 9).Remove(3, 1);
                AutoControl.MouseClick(int.Parse(x) + 20, int.Parse(y) + 20, EMouseKey.LEFT);
            }

            Thread.Sleep(500);

            //Send Enter ID
            try
            {
                AutoControl.SendStringFocus(txtBoxID.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Bạn chưa nhập ID");
            }


            //Click Join now
            var screenID = CaptureHelper.CaptureScreen();

            screenID.Save("mainScreen.png");
            var subBitmapID = ImageScanOpenCV.GetImage("btnVaoPhong.bmp");
            var resBitmapID = ImageScanOpenCV.FindOutPoint((Bitmap)screenID, subBitmapID);

            if (resBitmapID != null)
            {
                string x1 = (resBitmapID.ToString()).Remove(0, 3).Remove(3, 7);
                string y1 = (resBitmapID.ToString()).Remove(0, 9).Remove(3, 1);
                AutoControl.MouseClick(int.Parse(x1) + 20, int.Parse(y1) + 20, EMouseKey.LEFT);
            }
            Application.Exit();
        }
Exemple #17
0
        // This code does the actual "close" of the Capture SDK.

        public async Task <long> CloseCaptureClient(CaptureHelper captureHelper)
        {
            Console.WriteLine("Start CloseCaptureClient()");
            long result = await captureHelper.CloseAsync();

            Console.WriteLine("End CloseCaptureClient()");
            return(result);
        }
Exemple #18
0
        private void StartHmonCapture(IntPtr hmon)
        {
            GraphicsCaptureItem item = CaptureHelper.CreateItemForMonitor(hmon);

            if (item != null)
            {
                sample.StartCaptureFromItem(item);
            }
        }
Exemple #19
0
        /// <summary>
        ///     Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
        /// </summary>
        /// <param name="ignoreFailedRegistration">
        ///     if true, a failed hotkey registration will not be reported to the user - the
        ///     hotkey will simply not be registered
        /// </param>
        /// <returns>
        ///     Whether the hotkeys could be registered to the users content. This also applies if conflicts arise and the
        ///     user decides to ignore these (i.e. not to register the conflicting hotkey).
        /// </returns>
        public bool RegisterHotkeys(bool ignoreFailedRegistration)
        {
            var success    = true;
            var failedKeys = new StringBuilder();

            if (!RegisterWrapper(failedKeys, "CaptureRegion", "RegionHotkey",
                                 () =>
            {
                CaptureHelper.CaptureRegion(true);
            }, ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureWindow", "WindowHotkey", () =>
            {
                if (_coreConfiguration.CaptureWindowsInteractive)
                {
                    CaptureHelper.CaptureWindowInteractive(true);
                }
                else
                {
                    CaptureHelper.CaptureWindow(true);
                }
            }, ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureFullScreen", "FullscreenHotkey",
                                 () => CaptureHelper.CaptureFullscreen(true, _coreConfiguration.ScreenCaptureMode), ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureLastRegion", "LastregionHotkey", () => CaptureHelper.CaptureLastRegion(true), ignoreFailedRegistration))
            {
                success = false;
            }
            if (_coreConfiguration.IECapture)
            {
                if (!RegisterWrapper(failedKeys, "CaptureIE", "IEHotkey", () =>
                {
                    if (_coreConfiguration.IECapture)
                    {
                        CaptureHelper.CaptureIe(true, null);
                    }
                }, ignoreFailedRegistration))
                {
                    success = false;
                }
            }

            if (!success && !ignoreFailedRegistration)
            {
                success = HandleFailedHotkeyRegistration(failedKeys.ToString());
            }

            return(success || ignoreFailedRegistration);
        }
Exemple #20
0
        private void StartHwndCapture(IntPtr hwnd)
        {
            GraphicsCaptureItem item = CaptureHelper.CreateItemForWindow(hwnd);

            if (item != null)
            {
                sample.StartCaptureFromItem(item);
            }
        }
Exemple #21
0
 private void btnCapture_Click(object sender, EventArgs e)
 {
     if (!(ddWindows.SelectedItem is ProcessWrapper))
     {
         MessageBox.Show("Select window first.", "Screener", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     new PreviewForm(CaptureHelper.Capture(((ProcessWrapper)ddWindows.SelectedItem).Process.MainWindowHandle)).Show();
     Close();
 }
Exemple #22
0
        public static ImageCapture CaptureRectangle(Rect rect)
        {
            if (RemoveOutsideScreenArea)
            {
                Rect bounds = CaptureHelper.GetScreenBounds();
                rect = Rect.Intersect(bounds, rect);
            }

            return(new ImageCapture(CaptureRectangleNative(rect, CaptureCursor)));
        }
Exemple #23
0
        // The following routines are not functioning properly

#if false
        // Handler to display battery level changes on screen as they occur

        void OnDeviceBatteryLevel(object sender, CaptureHelper.BatteryLevelArgs e)
        {
            Console.WriteLine("Start OnDeviceBatteryLevel()");
            CurrentDevice.BatteryLevel = CaptureHelper.ConvertBatteryLevelInPercentage(e.MinLevel, e.MaxLevel, e.CurrentLevel);

            InvokeOnMainThread(() =>
            {
                battLevelLabel.Text = CurrentDevice.BatteryLevel;
            });
            Console.WriteLine("End OnDeviceBatteryLevel()");
        }
Exemple #24
0
 private void SnippingForm_AreaSelected(Rectangle rect)
 {
     while (_sfQueue.Count > 0)
     {
         SnippingForm form = _sfQueue.Dequeue();
         form.AreaSelected -= SnippingForm_AreaSelected;
         form.Close();
     }
     _areaSnippingMode = false;
     ShowPreview(CaptureHelper.Capture(rect));
 }
Exemple #25
0
 private void CaptureWindow()
 {
     if (conf.CaptureWindowsInteractive)
     {
         CaptureHelper.CaptureWindowInteractive(true);
     }
     else
     {
         CaptureHelper.CaptureWindow(true);
     }
 }
Exemple #26
0
 /// <inheritdoc />
 public void OpenFile(string filename)
 {
     Log.Debug().WriteLine("Open file requested: {0}", filename);
     if (File.Exists(filename))
     {
         CaptureHelper.CaptureFile(filename);
     }
     else
     {
         Log.Warn().WriteLine("No such file: {0}", filename);
     }
 }
        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                currentPosition    = CaptureHelper.GetCursorPosition();
                SelectionRectangle = CaptureHelper.CreateRectangle(positionOnClick.X, positionOnClick.Y, currentPosition.X, currentPosition.Y);

                CropArea.SetValue(Canvas.LeftProperty, SelectionRectangle0Based.Left);
                CropArea.SetValue(Canvas.TopProperty, SelectionRectangle0Based.Top);
                CropArea.Width  = SelectionRectangle0Based.Width;
                CropArea.Height = SelectionRectangle0Based.Height;
            }
        }
Exemple #28
0
        private void CaptureFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image files (*.png, *.jpg, *.gif, *.bmp, *.ico, *.tiff, *.wmf)|*.png; *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.tiff; *.tif; *.wmf";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(openFileDialog.FileName))
                {
                    CaptureHelper.CaptureFile(openFileDialog.FileName);
                }
            }
        }
 private void Window_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         positionOnClick = CaptureHelper.GetCursorPosition();
         isMouseDown     = true;
         canvas.Children.Add(CropArea);
     }
     else if (e.RightButton == MouseButtonState.Pressed)
     {
         Close();
     }
 }
Exemple #30
0
 private void RefreshLocalView()
 {
     this.LocalView.Dispatcher.BeginInvoke(new Action(() =>
     {
         try
         {
             LocalView.Source = CaptureHelper.BitmapToBitmapSource(_ScreenView);
         }
         catch (Exception ex)
         {
             Debug.Write($"Refresh Error:{ex.Message}");
         }
     }));
 }