Jump to content

Saving Coords in Variable


K3STROS
 Share

Recommended Posts

How would i go about saving a mouse position into a variable, atm i have this but im really not sure if its the proper way to do it

Im still very new to this

 

Global $xyLocation = MouseGetPos()

$Start_Exit_GUI = GUICreate("EXAMPLE", 228, 194, 398, 222) 
GUISetBkColor(0x0000FF)

$Loc_Button = GUICtrlCreateButton("GET LOCATION", 0, 0, 227, 89, $WS_GROUP) 
GUICtrlSetFont(-1, 28, 400, 0, "Absolute Zero")

$Exit_Button = GUICtrlCreateButton("EXIT", 0, 96, 227, 97, $WS_GROUP)
GUICtrlSetFont(-1, 28, 400, 0, "Absolute Zero")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Loc_Botton 
            LocButton()

        Case $Exit_Button 
            Terminate()

    EndSwitch
WEnd

Func LocButton()

    MsgBox(0, "NOTICE", "Click on the Location you want")

        MouseClick($xyLocation[0],$xyLocation[1]
        
    MsgBox(0, "LOCATION","Location has been set")

EndFunc 

Func Terminate()
    Exit 1
EndFunc

 

 

I want $xyLocation to hold whatever x-y Coordinates from where the user clicks AFTER the MsgBox() is gone

 

Thanks in advance for any help

Link to comment
Share on other sites

K3STROS,

You do not have any of the includes you need to define your GUI variables.

This "Case $Loc_Botton" is a spelling error.

All of which you would have seen if you ran the script from SciTe using F5.

You already have a MouseGetPos, just move it to wherever you want it

kylomas

 

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I think I understand WHAT he wanted

And you need "track" Mouse Left Click instead of use a function that clicks on determined coord

Dont miss Opt MouseCoordMode in help file:

Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window:

MouseCoordMode
0 = relative coords to the active window
1 = (default) absolute screen coordinates
2 = relative coords to the client area of the active window

#include <Misc.au3>

#cs

If are this you want then you need call MouseGetPos each time

#ce

Global $xyLocation

_GetMouseCoords()

Func _GetMouseCoords()

MsgBox(0, "NOTICE", "Click on the Location you want")

; 01 = Left Click
While _IsPressed("01") = False

Sleep(20)

WEnd

$xyLocation = MouseGetPos()

MsgBox(0, "LOCATION","Location has been set" & @CRLF & " X: " & $xyLocation[0] & " - Y: " & $xyLocation[1] & @CRLF)



EndFunc;_GetMouseCoords

 

Edited by GordonFreeman
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

×
×
  • Create New...