Jump to content
Sign in to follow this  
HankHell

Find Screen Coords

Recommended Posts

HankHell

figured I should post this since it might help someone out there.

#include <MsgBoxConstants.au3>

HotKeySet("{`}", "GetMposMsgBox") ;press ` (the button left of 1) to get your current mouse position

HotKeySet("{F1}", "FindCenter") ;F1

HotKeySet("{F2}", "FindCenterLeft") ;F2
HotKeySet("{F3}", "FindCenterRight")    ;F3
HotKeySet("{F4}", "FindTopCenter")  ;F4
HotKeySet("{F5}", "FindBottomCenter")   ;F5

HotKeySet("{F6}", "FindTopLeftCorner")  ;F6
HotKeySet("{F7}", "FindTopRightCorner") ;F7
HotKeySet("{F8}", "FindBottomLeftCorner")   ;F8
HotKeySet("{F9}", "FindBottomRightCorner")  ;F9

HotKeySet("{1}", "FindQ1")  ;1
HotKeySet("{2}", "FindQ2")  ;2
HotKeySet("{3}", "FindQ3")  ;3
HotKeySet("{4}", "FindQ4")  ;4

HotKeySet("{5}", "FindBetweenQ1Q3Center")   ;5
HotKeySet("{6}", "FindBetweenQ2Q4Center")   ;6
HotKeySet("{7}", "FindBetweenQ1Q2Center")   ;7
HotKeySet("{8}", "FindBetweenQ3Q4Center")   ;8

HotKeySet("{q}", "FindQ1LeftCenter")    ;Q
HotKeySet("{w}", "FindQ1TopCenter") ;W

HotKeySet("{e}", "FindQ2RightCenter")   ;E
HotKeySet("{r}", "FindQ2TopCenter") ;R

HotKeySet("{a}", "FindQ3LeftCenter")    ;A
HotKeySet("{s}", "FindQ3BottomCenter")  ;S

HotKeySet("{d}", "FindQ4RightCenter")   ;D
HotKeySet("{f}", "FindQ4BottomCenter")  ;F

HotKeySet("{F10}", "FindAllPoints") ;F10

HotKeySet("{ESC}", "End") ;ESC to close the program

Global $BrushColor = 0x00FF00
Global $BrushWidth = 7

Global $Mpos_1 = ""
Global $Mpos_2 = ""

While 1
    Sleep(100)
WEnd

Func GetMposMsgBox()  ;`

    $Mpos = MouseGetPos()
    $Mpos_x = $Mpos[0]
    $Mpos_y = $Mpos[1]

    ConsoleWrite("x=" & $Mpos_x & "," & "y=" & $Mpos_y & "  ")
    Msgbox($MB_SYSTEMMODAL,"Mouse Coords", "x=" & $Mpos_x & " " & "y=" & $Mpos_y)

EndFunc

Func GetMpos();

    $Mpos = MouseGetPos()
    $Mpos_x = $Mpos[0]
    $Mpos_y = $Mpos[1]

    ConsoleWrite("x=" & $Mpos_x & "," & "y=" & $Mpos_y & "  ")

EndFunc

Func FindCenter()   ;F1
    MouseMove((@DesktopWidth / 2), (@DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindCenterLeft() ;F2
    MouseMove(0, (@DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindCenterRight() ;F3
    MouseMove(@DesktopWidth, (@DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindTopCenter() ;F4
    MouseMove((@DesktopWidth / 2), 0, 0)
    GetMposMsgBox()
EndFunc

Func FindBottomCenter() ;F5
    MouseMove((@DesktopWidth / 2), @DesktopHeight, 0)
    GetMposMsgBox()
EndFunc

Func FindBottomRightCorner()    ;F6
    MouseMove(@DesktopWidth, @DesktopHeight, 0)
    GetMposMsgBox()
EndFunc

Func FindTopRightCorner()   ;F7
    MouseMove(@DesktopWidth, 0, 0)
    GetMposMsgBox()
EndFunc

Func FindBottomLeftCorner() ;F8
    MouseMove(0, @DesktopHeight, 0)
    GetMposMsgBox()
EndFunc

Func FindTopLeftCorner() ;F9
    MouseMove(0, 0, 0)
    GetMposMsgBox()
EndFunc

Func FindQ1()   ;1
    MouseMove((@DesktopWidth / 4), (@DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ2()   ;2
    MouseMove ((3 * @DesktopWidth / 4), (@DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ3()   ;3
    MouseMove ((@DesktopWidth / 4), (3 * @DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ4()   ;4
    MouseMove ((3 * @DesktopWidth / 4), (3 * @DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindBetweenQ1Q3Center();5
    MouseMove((@DesktopWidth / 4), (@DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindBetweenQ2Q4Center();6
    MouseMove((3 * @DesktopWidth / 4), (@DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindBetweenQ1Q2Center();7
    MouseMove((@DesktopWidth / 2), (@DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindBetweenQ3Q4Center();8
    MouseMove(@DesktopWidth / 2, (3 * @DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ1LeftCenter();Q
    MouseMove(0, (@DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ1TopCenter()  ;W
    MouseMove((@DesktopWidth / 4), 0, 0)
    GetMposMsgBox()
EndFunc

Func FindQ2RightCenter();E
    MouseMove(@DesktopWidth, (@DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ2TopCenter();R
    MouseMove((3 * @DesktopWidth / 4), 0, 0)
    GetMposMsgBox()
EndFunc

Func FindQ3LeftCenter();A
    MouseMove(0, (3 * @DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ3BottomCenter();S
    MouseMove((@DesktopWidth / 4), (3 * @DesktopHeight / 2), 0)
    GetMposMsgBox()
EndFunc

Func FindQ4RightCenter();D
    MouseMove(@DesktopWidth, (3 * @DesktopHeight / 4), 0)
    GetMposMsgBox()
EndFunc

Func FindQ4BottomCenter();F
    MouseMove((3 * @DesktopWidth / 4), @DesktopHeight, 0)
    GetMposMsgBox()
EndFunc

Func FindAllPoints()    ;F10

If 1 Then

    MouseMove((@DesktopWidth / 2), (@DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove(0, (@DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth, (@DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 2), 0, 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 2), @DesktopHeight, 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth, @DesktopHeight, 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth, 0, 0)
    SetPixel()
    GetMpos()
    MouseMove(0, @DesktopHeight, 0)
    SetPixel()
    GetMpos()
    MouseMove(0, 0, 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 4), (@DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove ((3 * @DesktopWidth / 4), (@DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove ((@DesktopWidth / 4), (3 * @DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((3 * @DesktopWidth / 4), (3 * @DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 4), (@DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove((3 * @DesktopWidth / 4), (@DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 2), (@DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth / 2, (3 * @DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove(0, (@DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 4), 0, 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth, (@DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((3 * @DesktopWidth / 4), 0, 0)
    SetPixel()
    GetMpos()
    MouseMove(0, (3 * @DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((@DesktopWidth / 4), (3 * @DesktopHeight / 2), 0)
    SetPixel()
    GetMpos()
    MouseMove(@DesktopWidth, (3 * @DesktopHeight / 4), 0)
    SetPixel()
    GetMpos()
    MouseMove((3 * @DesktopWidth / 4), @DesktopHeight, 0)
    SetPixel()
    GetMpos()
EndIf
EndFunc

Func SetPixel()

    $Mpos = MouseGetPos()
    $Mpos_x = $Mpos[0]
    $Mpos_y = $Mpos[1]

    $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    $pen = DllCall("GDI32.dll", "int", "CreatePen", "int", 0, "int", $BrushWidth, "int", $BrushColor)
        DllCall("GDI32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
        DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $Mpos_x, "int", $Mpos_y, "int", 0)
        DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Mpos_x, "int", $Mpos_y)
            DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])
    $Mpos_x = 0
    $Mpos_y = 0
    $Mpos = 0

EndFunc

Func End()
    Exit
EndFunc

it will find all the corners, centers, and quadrants of your current screen, regardless of resolution; makes it easier to find GUI positions

Edited by HankHell

Share this post


Link to post
Share on other sites
HankHell

<code edited> now it makes a grid, and specifies all the points where x and y intersect

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×