Example #1
0
        private bool findClick(Process process, Image img)
        {
            IntPtr hWnd = process.MainWindowHandle;
            Image wnd = ScreenCapture.CaptureWindow(hWnd);
               //((Bitmap)wnd).Save("dump.bmp");
            Point location;
            bool success = find((Bitmap)img, (Bitmap)wnd, out location);
            if (success)
            {
                Debug.Print("Success");

                //support for relativity
                //Point windLoc = hWnd.GetWindowLocation();
                location = img.AlmostCenter(location, 3);
                //location.X += windLoc.X;
                //location.Y += windLoc.Y;
                if (Extensions.GetActiveWindowTitle() != "PVP.net Client")
                {
                    process.SwitchTo();
                }
                //Mouse.pointClick(location);
                //VirtualMouse.Click(hWnd, (ushort)location.X, (ushort)location.Y );
                VirtualMouse.Click(hWnd, VirtualMouse.WMessages.WM_LBUTTONDOWN, location);
                VirtualMouse.Click(hWnd, VirtualMouse.WMessages.WM_LBUTTONUP, location);
                //VirtualMouse.ControlClickWindow(hWnd, "left", location.X, location.Y, false);
            }
            wnd.Dispose();
            return success;
        }