Jump to content

Been looking but not finding, get coordinates of mouseclick


Recommended Posts

I've been trying to figure out how to make a function to remap locations.

I'd like to have it so that you click a button "Map coordinates", and then click on the locations.

I know how to get the mouse coordinates, but I can't figure out how to trigger a function when the mouse button is clicked in other windows.

Link to comment
Share on other sites

#include <Misc.au3>
#include <GuiConstants.au3>

$GUICoord = GUICreate('Mouse Finder Tool', '150', '20', '-1', '-1', '-1', '128')
Global $CoordInput = GUICtrlCreateInput('', '0', '0', '150', '20', '1')
GUICtrlSetFont($CoordInput, '9', '600', '', 'Arial')
GUICtrlSetState($CoordInput, $GUI_DISABLE)
GUISetState(@SW_SHOW, $GUICoord)
WinSetOnTop($GUICoord, '', '1')
AdlibRegister("RefreshCoord", 50)

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("01", $hDLL) Then
        $Pos = MouseGetPos()
        ConsoleWrite("X: " & $Pos['0'] & "  Y: " & $Pos['1'] & @CRLF)
        While _IsPressed("01")
            Sleep(1)
        WEnd
    EndIf
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

DllClose($hDLL)
AdlibUnRegister("RefreshCoord")
GUIDelete($GUICoord)

Func RefreshCoord()
    $Pos = MouseGetPos()
    GUICtrlSetData($CoordInput, "X: " & $Pos['0'] & "  Y: " & $Pos['1'])
EndFunc

Edited by Rogue5099
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...