Guest Demvaril Posted September 6, 2004 Share Posted September 6, 2004 (edited) Hi , I need a macro that will hit the same key between 2 set times. For example hit the "x" key at a random time between 45 and 50 secs. At the moment I have a macro that hits the same key at a preset time, like 45000 for 45 seconds. I am not at work at the moment so cannot show the macro i have, but it was a pretty simple one. Thanks for any help. been to work and this is the script i am using $i = 0 Do Sleep(52000) Send("s") Until $i = 1 Would adding Sleep(Random(2000, 5000)) at the end of the script work? or should i replace "Sleep(52000)" with "Sleep(Random(52000, 55000)) Any help appreciated. Edited September 6, 2004 by Demvaril Link to comment Share on other sites More sharing options...
ezzetabi Posted September 6, 2004 Share Posted September 6, 2004 (edited) Dim $mint, $maxt $mint = 45 ;Set the min time in seconds. $maxt = 50 ;Set the max time in seconds. If $maxt < $mint Then Exit While 1 Sleep($mint * 1000) Sleep(Int(Random($maxt - $mint + 1)) * 1000) ;* Send('s') Wend ;* The point to this line is calculate the max time the script should sleep. ;adding 1 to it (since Random() do not include max in its results) truncate ;decimal part of the Random result and sleep that number of seconds. Edited September 6, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
Developers Jos Posted September 6, 2004 Developers Share Posted September 6, 2004 Dim $mint, $maxt $mint = 45 ;Set the min time in seconds. $maxt = 50 ;Set the max time in seconds. If $maxt < $mint Then Exit While 1 Sleep($mint * 1000) Sleep(Int(Random($maxt - $mint + 1)) * 1000);* Send('s') Wend ;* The point to this line is calculate the max time the script should sleep. ;adding 1 to it (since Random() do not include max in its results) truncate ;decimal part of the Random result and sleep that number of seconds. <{POST_SNAPBACK}>Think it can also be done with one sleep command: Sleep(Random($mint,$maxt) * 1000) 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...
ezzetabi Posted September 6, 2004 Share Posted September 6, 2004 Of course, but it seemed more clear for a noob to me. Btw your code never arrive waiting to $maxt seconds It should be: Sleep(Int(Random($mint,$maxt + 1)) * 1000) Link to comment Share on other sites More sharing options...
Developers Jos Posted September 7, 2004 Developers Share Posted September 7, 2004 Of course, but it seemed more clear for a noob to me. Btw your code never arrive waiting to $maxt seconds It should be: Sleep(Int(Random($mint,$maxt + 1)) * 1000) <{POST_SNAPBACK}>You are rigth... I am of 1/1000s of a second 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...
Guest Demvaril Posted September 7, 2004 Share Posted September 7, 2004 Thank you very much. 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