Ousapik Posted August 2, 2009 Posted August 2, 2009 Hello, I want to use mouse coord and click or drag at these coord when i want, but the mouse coord where i want to clic or drag change so i use a hotkey which store the position when it change. I tried to make a script using MouseGetPos, MousClick and MouseClickDrag , draging or click at a fixed position i was successful but when i tried to hotkey a function to "save" the mouse position with MousegetPos, autoIt tell me "Variable used without being declared." I tried these functions Func Start() $StartPos = MouseGetPos() EndFunc Func Drag() $DragPos = MouseGetPos() MouseClickDrag("left", $DragPos[0], $DragPos[1], $StartPos[0], $StartPos[1], 0) EndFunc Func Click() MouseClick("left", [,$StartPos[0], $StartPos[1] [,1 [,0]]]) EndFunc When i use the hotkey for Start i dont "save" the coords and i have an error.
Authenticity Posted August 2, 2009 Posted August 2, 2009 Your script should declare global variable so the variables referenced by a function won't be assumed local variables. Global $StartPos ; ... ; .. Func Start() $StartPos = MouseGetPos() EndFunc Func Drag() $DragPos = MouseGetPos() If IsArray($StartPos) Then _ MouseClickDrag("left", $DragPos[0], $DragPos[1], $StartPos[0], $StartPos[1], 0) EndFunc Func Click() MouseClick("left", [,$StartPos[0], $StartPos[1] [,1 [,0]]]) EndFunc ..this way the $DragPos is local but it only get referenced by the function defining it.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now