Luzian Posted December 24, 2012 Share Posted December 24, 2012 (edited) Dear fellow AutoIt usersI am currently working on my first script because of personal interest, the script itself will most likely be useless and 'use for fun'. However I am currently stuck and Google did not really help much... Please help me!The goal of the script is to execute short tasks including mouse movement.Here is an abstract code prototype to help understanding of the problem, do not use it as guideline:HotKeySet('{LCTRL}+K', 'CoordGet') ;hotkeys for tasks HotkeySet('{ESC}', 'Terminate') Func CoordGet() ;grabbing coordinates using: $MousePos=MouseGetPos() CoordX[0] = MousePos[0], CoordY[0] = MousePos[0] EndFunc Func example() MouseMove (CoordX[0], CoordY[0], 0) EndFunc Func Terminate() Exit EndFuncProblem:I want to implement a function CoordGet that saves the current coordinates of my mouse into an array so I can use them laterMy Ideas:I already thought about different ways to implement the function:- using Do MouseGetPos Until (isn't this resource heavy since it grabs many unneeded coordinates)- using nested while loops with a toggle for the whole function (makes it hotkey and code heavy)- just writing the code to grab 2-3 coordinates when the script is started and using a hotkey as signal to get the current coordinates (really inflexible, cannot reassign coordinates, I don't know how to let the script wait for the specific hotkey input)Question:Can you recommend and show elegant and simple solutions for a function executed when pressing a hotkey that grabs hotkeys and enters them into arrays until the function is ended? Alternatively less efficient and flexible solutions would work as well if they are easier to implement.Thank you a lot for every helpful reply! Edited December 24, 2012 by Luzian Link to comment Share on other sites More sharing options...
kylomas Posted December 24, 2012 Share Posted December 24, 2012 Luzian,grabs hotkeysDo you mean "grabs mouse coords"?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 More sharing options...
Luzian Posted December 24, 2012 Author Share Posted December 24, 2012 Do you mean "grabs mouse coords"? Yes, thank you for pointing out that typo... Unfortunately I seem to be unable to edit my original post. My temporary bad solution is: Global $CoordX[x] Global $CoordY[x] HotKeySet('{LCTRL}+K+1', 'CoordGet1') HotKeySet('{LCTRL}+K+2', 'CoordGet2') ;... Func CoordGet1() $MousePos=MouseGetPos() $CoordX[0]=$MousePos[0] $CoordY[0]=$MousePos[1] EndFunc Func CoordGet2() $MousePos=MouseGetPos() $CoordX[1]=$MousePos[0] $CoordY[1]=$MousePos[1] EndFunc ;... Unfortunately my inexperience in AutoIt clearly shows in my amateur code... Link to comment Share on other sites More sharing options...
kylomas Posted December 24, 2012 Share Posted December 24, 2012 (edited) Luzian, We all start somewhere. I don't know much about mouse related shit but here's something that might help. ; ; ; #include <Misc.au3> #include <array.au3> local $hDLL = DllOpen("user32.dll") local $mouse_coords[1][2] while 1 if _ispressed('1b') then exit if _ispressed('01') then $mouse_coords[ubound($mouse_coords) - 1][0] = mousegetpos(0) $mouse_coords[ubound($mouse_coords) - 1][1] = mousegetpos(1) redim $mouse_coords[ubound($mouse_coords)+1][2] _arraydisplay($mouse_coords) EndIf sleep(100) wend kylomas edit: sorry, forgot explanation. This records left mouse click in an array. The array is displayed just to see it working. Edited December 24, 2012 by 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 More sharing options...
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