open System.Windows.Forms open System.Runtime.InteropServices #nowarn "9" [] type POINT = new (x, y) = { X = x; Y = y } val X : int val Y : int [] extern nativeint GetForegroundWindow(); [] extern int ScreenToClient(nativeint hWnd, POINT &pt); let GetMousePosition() = let hwnd = GetForegroundWindow() let pt = Cursor.Position let mutable ptFs = new POINT(pt.X, pt.Y) ScreenToClient(hwnd, &ptFs) |> ignore ptFs