Jump to content
Sign in to follow this  

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.

Share this post

Link to post
Share on other sites

See _IsPressed() in the Help file.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post

Link to post
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")
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop


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

Edited by Rogue5099

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.