Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Mouse-position/F-Sharp/mouse-position.fs
Normal file
21
Task/Mouse-position/F-Sharp/mouse-position.fs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
open System.Windows.Forms
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
#nowarn "9"
|
||||
[<Struct; StructLayout(LayoutKind.Sequential)>]
|
||||
type POINT =
|
||||
new (x, y) = { X = x; Y = y }
|
||||
val X : int
|
||||
val Y : int
|
||||
|
||||
[<DllImport("user32.dll")>]
|
||||
extern nativeint GetForegroundWindow();
|
||||
[<DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true, ExactSpelling=true)>]
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue