private static int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { //Marshall the data from the callback. MouseHookStruct MyMouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct)); if (nCode < 0) { return(CallNextHookEx(hHook, nCode, wParam, lParam)); } else { //Create a string variable that shows the current mouse coordinates. String strCaption = "x = " + MyMouseHookStruct.pt.x.ToString("d") + " y = " + MyMouseHookStruct.pt.y.ToString("d"); //You must get the active form because it is a static function. Form tempForm = Form.ActiveForm; //Set the caption of the form. tempForm.Text = strCaption; if (true) { CameraShooter.RECT rr = new Rectangle(0, 0, 10000, 10000); CameraShooter.ClipCursor(ref rr); } return(CallNextHookEx(hHook, nCode, wParam, lParam)); } }
public static void ClickOffset(this IntPtr control, Point offset) { CPrint2.CameraShooter.RECT r2; CameraShooter.GetWindowRect(control, out r2); var p2 = r2.LeftTop(); p2.Offset(offset); CameraShooter.SetForegroundWindow(control); MouseOperations.MouseEventXY(p2.X, p2.Y, MouseEventFlags.LeftDownUp); }
public static void MoveWinPos(this IntPtr hWnd, int x, int y) { CameraShooter.SetWindowPos(hWnd, IntPtr.Zero, x, y, 0, 0, CameraShooter.SWP_NOZORDER | CameraShooter.SWP_NOSIZE | CameraShooter.SWP_SHOWWINDOW); }