BogdanNicolescu Posted February 8, 2020 Share Posted February 8, 2020 Hi there, I've got this: Global $Paused=True , $counter = 34 HotKeySet("{F6}", "TogglePause") HotKeySet("{F7}", "Terminate") While 1 If Not $Paused Then ;to see if paused or not Sleep(150) MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time Sleep(150) ; wait MouseClick("left",1024,574,1,15) ; Click on a button Sleep(150) ; wait MouseClick("left",617,536,1,15) ; Click on "ANOTHER" button Sleep(50) ; wait Send("^!+c") ; Send key combination Sleep(150) ; wait EndIf Sleep(10) WEnd Func TogglePause() $Paused= Not $Paused;if true set to false and vice versa EndFunc Func Terminate() ;exit Exit EndFunc What i want do be able to do, is to make this part: MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time Sleep(150) ; wait click for a specific amount of time with delay of clicks of 90 miliseconds. Where is that help file where it says what i need? Thank you. Link to comment Share on other sites More sharing options...
Nine Posted February 8, 2020 Share Posted February 8, 2020 Look at Opt for : MouseClickDelay Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10). MouseClickDownDelay Alters the length a click is held down before release. Time in milliseconds to pause (default=10). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 2 hours ago, Nine said: Look at Opt for : MouseClickDelay Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10). MouseClickDownDelay Alters the length a click is held down before release. Time in milliseconds to pause (default=10). Wont help me. This i understand how to use time in between clicks, but i want to MULTI-click for a specific amount of time, let's say 15 minutes, then execute the rest of the code. For example, i want the code to click multiple times in a specific area for 15 minute ... mor or less. I don't want to click and hold for a specific amount of time, but to click 1000 times with 90 milliseconds or 100 between clicks or for 15 minutes ... mor or less. Thank you. Link to comment Share on other sites More sharing options...
JuanFelipe Posted February 8, 2020 Share Posted February 8, 2020 According to what I understand, use a For For $i = 0 To 15 Step 1 MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time Sleep(1000) ; wait Next Modify the sleep to match the number of repetitions you want. Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 25 minutes ago, JuanFelipe said: According to what I understand, use a For For $i = 0 To 15 Step 1 MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time Sleep(1000) ; wait Next Modify the sleep to match the number of repetitions you want. Couldn't i say somewhere something like: MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time Timer: 15 min or some sort of ... And sleep is not a function (or what ever it is) that tells to wait/pause/halt/do nothing that amount of time? Thank you. Link to comment Share on other sites More sharing options...
JuanFelipe Posted February 8, 2020 Share Posted February 8, 2020 No, because a code is running down, then you need to use a cycle to repeat the action you need to use, what you can do is use the For, change the sleep and the limit of the For to do what you want, exactly what do you need? Link to comment Share on other sites More sharing options...
Nine Posted February 8, 2020 Share Posted February 8, 2020 51 minutes ago, BogdanNicolescu said: Wont help me. This i understand how to use time in between clicks, but i want to MULTI-click for a specific amount of time, let's say 15 minutes, then execute the rest of the code. For example, i want the code to click multiple times in a specific area for 15 minute ... mor or less. I don't want to click and hold for a specific amount of time, but to click 1000 times with 90 milliseconds or 100 between clicks or for 15 minutes ... mor or less. I think you do not understand my point (unless it is me that don't understand you). This is what I was telling you : Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay Const $iInterval = 90 ; interval between clicks Const $iDuration = 1000 * 60 ; * 15 -- but for test lets says 1 minute Opt ("MouseClickDelay", $iInterval) ; this is what you want, right ? Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration)) Local $hTimer = TimerInit () MouseClick ("left", 200, 200, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration ConsoleWrite (TimerDiff ($hTimer) & @CRLF) BogdanNicolescu 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 30 minutes ago, Nine said: I think you do not understand my point (unless it is me that don't understand you). This is what I was telling you : Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay Const $iInterval = 90 ; interval between clicks Const $iDuration = 1000 * 60 ; * 15 -- but for test lets says 1 minute Opt ("MouseClickDelay", $iInterval) ; this is what you want, right ? Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration)) Local $hTimer = TimerInit () MouseClick ("left", 200, 200, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration ConsoleWrite (TimerDiff ($hTimer) & @CRLF) And how exactly do i put this in my code? It will work with the rest of what i have? Link to comment Share on other sites More sharing options...
Nine Posted February 8, 2020 Share Posted February 8, 2020 2 minutes ago, BogdanNicolescu said: And how exactly do i put this in my code? It will work with the rest of what i have? Sorry, you will need to figure out that by yourself. Unless a good Samaritan will spew it for you. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) How do i use this: Local $hTimer = TimerInit () And how do i get rid of: Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay Because i already have this: Const $iInterval = 90 ; interval between clicks Edited February 10, 2020 by BogdanNicolescu misspelling Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 9 minutes ago, Nine said: Sorry, you will need to figure out that by yourself. Unless a good Samaritan will spew it for you. whelp ... i guess that'l would be me, quite thank you 😄😃😁 Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) While 1 If Not $Paused Then ;to see if paused or not Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay Const $iInterval = 90 ; interval between clicks Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute Opt ("MouseClickDelay", $iInterval) ; this is what you want, right ? Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration)) Local $hTimer = TimerInit () MouseClick ("left", 721, 550, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration ConsoleWrite (TimerDiff ($hTimer) & @CRLF) MouseClick("left",1024,574,1,15) ; Click on a button Sleep(150) ; wait EndIf Sleep(10) WEnd And why do i get this error? >"X:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "X:\Users\User\Documents\!Automation\testclick.au3" 3315.37433271884 "X:\Users\User\Documents\!Automation\testclick.au3" (9) : ==> Can not redeclare a constant.: Const $iClickDuration = 90 Const ^ ERROR >Exit code: 1 Time: 10.6 Edited February 8, 2020 by BogdanNicolescu Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2020 Developers Share Posted February 8, 2020 6 minutes ago, BogdanNicolescu said: And why do i get this error? The error does exactly tell you what is wrong,,,,right? Jos BogdanNicolescu 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 1 minute ago, Jos said: The error does exactly tell you what is wrong,,,,right? Jos Any hint would be much appreciated as i'm looking at something resembling like klingonian (i don't want to offend Chinese/Japanese people that would be here ) and for now i can't understand why i'm getting this. Tried to change from 90 to 10, but no avail ... Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) On 2/8/2020 at 7:00 PM, Jos said: The error does exactly tell you what is wrong,,,,right? Jos Thank you Master Yoda ... aaahmm sorry Jos, for sending me telepathically the response :)) Btw ... what are these "lines"? >"x:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "x:\Users\User\Documents\!Automation\testclick.au3" 3324.26151305731 3317.95812692394 3321.5178334804 3320.48891723529 3315.3012339423 3323.39248218399 3318.81172259742 >Exit code: 0 Time: 47.12 Edited February 10, 2020 by BogdanNicolescu misspelling Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) After a full day's worth of brain squeezing (not really, I've been doing other stuff in between :)) ) all i have right now is this: Global $Paused=True , $counter = 34 HotKeySet("{F6}", "TogglePause") HotKeySet("{F7}", "Terminate") Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay Const $iInterval = 90 ; interval between clicks Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute While 1 If Not $Paused Then ;to see if paused or not Opt ("MouseClickDelay", $iInterval) ; this is what you want, right ? Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration)) Local $hTimer = TimerInit () MouseClick ("left", 721, 550, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration ConsoleWrite (TimerDiff ($hTimer) & @CRLF) MouseClick("left",1024,574,1,15) ; Click on a button Sleep(150) ; wait EndIf Sleep(10) WEnd Func TogglePause() $Paused= Not $Paused;if true set to false and vice versa EndFunc Func Terminate() ;exit Exit EndFunc LE P.S.: How do i force pause or force stop? Because even if i press F7, it takes some time to stop. Edited February 8, 2020 by BogdanNicolescu Link to comment Share on other sites More sharing options...
seadoggie01 Posted February 8, 2020 Share Posted February 8, 2020 Your request seems a bit odd... maybe you can tell us what you're using the script for so we can better assist you? I've never needed to click for a specific amount of time like this and there could be a better way. To force pause your script, you're going to need to write a wrapper for MouseClick since it will block exiting for the remainder of your duration... basically a function that is a single MouseClick wrapped in a for loop All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) On 2/8/2020 at 8:42 PM, seadoggie01 said: Your request seems a bit odd... maybe you can tell us what you're using the script for so we can better assist you? I've never needed to click for a specific amount of time like this and there could be a better way. To force pause your script, you're going to need to write a wrapper for MouseClick since it will block exiting for the remainder of your duration... basically a function that is a single MouseClick wrapped in a for loop Hi, and helo there, welcome to our little party I will not go into details because already the amount of the code that i have is already heavy on my brain and my brain is struggling to understand what is what and where is where and why the baloneys is everything where it is. For instance, i didn't know that i've had to put this: Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay Const $iInterval = 90 ; interval between clicks Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute where it is. It was only after Master Yoda JOS sent me telepathically the answer i could understand and get rid of this error:"X:\Users\User\Documents\!Automation\testclick.au3" (9) : ==> Can not redeclare a constant.:Const $iClickDuration = 90Const ^ ERROR So any other complicated codes will be redundant as what i have is kind of working. Needs more tweaking tho ... As per what you said: "you're going to need to write a wrapper for MouseClick" How do i do that? Can you provide some "eg.:" P.S.: For those who knows better this program, would be nice for you if you came up with some examples or something of some sort, not just "figure out" "read this nothing non-sense" "ask the Univers". Otherwise ... why this site exists :))))) :))))) Edited February 10, 2020 by BogdanNicolescu Link to comment Share on other sites More sharing options...
seadoggie01 Posted February 8, 2020 Share Posted February 8, 2020 (edited) Basically, when you call an internal function, it might take time to execute. You cannot interrupt these functions whenever you want with another event (pressing F7 to stop, for example). More specifically: When you say MouseClick("left", 721, 550, $iNumberOfClicks, 0), AutoIt starts clicking in that spot $iNumberOfClicks times. Each of these clicks takes time (yours take longer because you've changed some options), and AutoIt will execute ALL of these clicks before doing anything else. If you write a function like the one below, AutoIt clicks once inside of the loop and returns to checking events. This will reduce the amount of time it takes after you press F7 to a length of one click ; This function will be able to be interrupted better because it clicks one at a time Func _MouseClickWrapper($sButton, $iX, $iY, $iClicks, $iSpeed = 10) ; For each click For $i = 0 To $iClicks ; Click once with the requested parameters MouseClick($sButton, $iX, $iY, 1, $iSpeed) Next EndFunc I find it interesting that you still haven't mentioned what this is for 😐 Edited February 8, 2020 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
BogdanNicolescu Posted February 8, 2020 Author Share Posted February 8, 2020 11 minutes ago, seadoggie01 said: Basically, when you call an internal function, it might take time to execute. You cannot interrupt these functions whenever you want with another event (pressing F7 to stop, for example). More specifically: When you say MouseClick("left", 721, 550, $iNumberOfClicks, 0), AutoIt starts clicking in that spot $iNumberOfClicks times. Each of these clicks takes time (yours take longer because you've changed some options), and AutoIt will execute ALL of these clicks before doing anything else. If you write a function like the one below, AutoIt clicks once inside of the loop and returns to checking events. This will reduce the amount of time it takes after you press F7 to a length of one click ; This function will be able to be interrupted better because it clicks one at a time Func _MouseClickWrapper($sButton, $iX, $iY, $iClicks, $iSpeed = 10) ; For each click For $i = 0 To $iClicks ; Click once with the requested parameters MouseClick($sButton, $iX, $iY, 1, $iSpeed) Next EndFunc I find it interesting that you still haven't mentioned what this is for 😐 Not working, i still need to press like crazy on stop button ... Link to comment Share on other sites More sharing options...
Recommended Posts