dredrox Posted May 10, 2021 Share Posted May 10, 2021 Hello I have recently started learning autoit, learned quite a bit about mousemove and click, but i have no clue and cant seem to find, well maybe i don't know how to search, how to increase for example x axis for each mouseclick. Lets say i have 5 buttons on the same x axis and they are separated by exactly 50 pixels, how could i make mouse move to first, click, move to second, click etc? I could write a function for each one of them, but it seem inefficient and what if i have 50 or more points to click. Thanks in advance and sorry if this is duplicate. Link to comment Share on other sites More sharing options...
Sidley Posted May 10, 2021 Share Posted May 10, 2021 There's probably people on here who can pretty this up no end, but this should do you #include <AutoItConstants.au3> #include <Misc.au3> Local $aMousePos Local $i While Not _IsPressed('1B') ;Do until ESC key is pressed If _IsPressed('01') Then ;If left mouse button is clicked $aMousePos = MouseGetPos() ;Returns an array [0]=X position, [1]=Y position For $i=0 To 4 ;Loop from 0 to 4 $aMousePos[0] += 50 ;Each time add 50 pixels to the X position MouseMove($aMousePos[0], $aMousePos[1]) ;Move the mouse to (New X position, original Y position) ConsoleWrite($aMousePos[0] + @CRLF) ;For debugging purposes, remove if you want MouseClick($MOUSE_CLICK_LEFT) ;Click the left mouse button Next EndIf WEnd dredrox 1 Link to comment Share on other sites More sharing options...
argumentum Posted May 10, 2021 Share Posted May 10, 2021 4 minutes ago, Sidley said: If _IsPressed('01') Then ;If left mouse button is clicked I'd do a loop to wait until Not _IsPressed() after the _IsPressed() and then act on it. 37 minutes ago, dredrox said: I have recently started learning autoit, learned quite a bit about mousemove and click, ... ... Lets say i have 5 buttons on the same x axis and they are separated by exactly 50 pixels, ... ... what if i have 50 or more points to click. A whole lot of clicking there. Do read about automating things we don't here at the forum. And welcome to the forum @dredrox Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
dredrox Posted May 10, 2021 Author Share Posted May 10, 2021 41 minutes ago, Sidley said: There's probably people on here who can pretty this up no end, but this should do you #include <AutoItConstants.au3> #include <Misc.au3> Local $aMousePos Local $i While Not _IsPressed('1B') ;Do until ESC key is pressed If _IsPressed('01') Then ;If left mouse button is clicked $aMousePos = MouseGetPos() ;Returns an array [0]=X position, [1]=Y position For $i=0 To 4 ;Loop from 0 to 4 $aMousePos[0] += 50 ;Each time add 50 pixels to the X position MouseMove($aMousePos[0], $aMousePos[1]) ;Move the mouse to (New X position, original Y position) ConsoleWrite($aMousePos[0] + @CRLF) ;For debugging purposes, remove if you want MouseClick($MOUSE_CLICK_LEFT) ;Click the left mouse button Next EndIf WEnd Thank you very much, that's what i needed, i understand it enough to modify and play with the code further.. this was my newbie try to do it on my own, probably bunch of useless stuff and doesn't even do what i want... Quote $mousemovex = 999 $mousemovey = 777 $offsetx = 0 $mouseclick = MouseClick For $offsetx = 0 to 250 Step 50 if $MouseClick = MouseClick("right", $mousemovex + $offsetx,$mousemovey, 1,100) Then $offsetx =+50 EndIf Next Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 10, 2021 Moderators Share Posted May 10, 2021 14 minutes ago, dredrox said: probably bunch of useless stuff and doesn't even do what i want... Then you need to explain more clearly what it is you're trying to accomplish, beyond "just testing". Show a screenshot of what you are trying to click on, or at the very least add a detailed description such as "I want to open application x, click on button a, then button b, then menu c". You will find, 99% of the time, there is a better way to accomplish what you are after, but we need more info to help. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
dredrox Posted May 10, 2021 Author Share Posted May 10, 2021 1 minute ago, JLogan3o13 said: Then you need to explain more clearly what it is you're trying to accomplish, beyond "just testing". Show a screenshot of what you are trying to click on, or at the very least add a detailed description such as "I want to open application x, click on button a, then button b, then menu c". You will find, 99% of the time, there is a better way to accomplish what you are after, but we need more info to help. I am sorry if i got misunderstood, already got what i needed from @Sidley . Thing you quoted was about my code, not his. 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