Hi,
I have a script With containing a couple hundred sleep funcitons.
I was wondering if anyone knows a simple and smart way to change all those timings easily on the go?
I'll draft out an example of what I want to be able to do:
Let's say I have a checkbox, where the user can check it for superspeed, and uncheck it for slower speed.
When the checkbox is checked, I want to divide all sleep timings by 2.
Anyone knows how to do this, or maybe someone has a better way of creating something similar?
Possible to change all sleep timings?
Re: Possible to change all sleep timings?
Code: Select all
checked:=0
sleeptime:=2000
If (checked)
sleeptime/=2
msgbox %sleeptime%
sleep,%sleeptime%
checked:=1
If (checked)
sleeptime/=2
msgbox %sleeptime%
sleep,%sleeptime%
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: Possible to change all sleep timings?
change your sleep amounts to a variable then you can use a gui to change the size of all the sleeps in one place, or if you have many sleep sizes the have the number to divide by as a variable
Code: Select all
sleep_amout := 1000
divider := 2
sleep, sleep_amout ; sleeps 1000
sleep, sleep_amout/divider ; sleeps 500
Courses on AutoHotkey
My Autohotkey Blog
Re: Possible to change all sleep timings?
I've thought of that, but it's a really time consuming Method, I mean, creating 200 variables...
Re: Possible to change all sleep timings?
I should maybe add something, I think it would open up for more solutions.
It doesn't have to change "on the go" as I wrote, but would it maybe be possible to create an external script that parses through the main script, then dividing or multiplying every sleep function?
simple pseudo example:
parse main script line by line
if line contains "sleep "
loop parse line
if x is number
divide x by 2
It doesn't have to change "on the go" as I wrote, but would it maybe be possible to create an external script that parses through the main script, then dividing or multiplying every sleep function?
simple pseudo example:
parse main script line by line
if line contains "sleep "
loop parse line
if x is number
divide x by 2
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: Possible to change all sleep timings?
why not change them to variables instead of dividing the number?
variables gives you way more rum for improving your functionality overtime
and why do you need 200 variables? simply use expressions so you variant them using math
variables gives you way more rum for improving your functionality overtime
and why do you need 200 variables? simply use expressions so you variant them using math
Code: Select all
sleep_amout := 1000
sleep, sleep_amout ; sleeps 1000
sleep, sleep_amout/2 ; sleeps 500
sleep, sleep_amout*3 ; sleeps 3000
sleep, sleep_amout*10 ; sleeps 10000
sleep, sleep_amout/3.3 ; sleeps 303.03
Courses on AutoHotkey
My Autohotkey Blog
Re: Possible to change all sleep timings?
That would take even longer considering I have pretty specific timings, but would be easier to manage I Guess..
Thing is, I have very small, specific and different timings..
example:
sleep 30
sleep 40
sleep 60
sleep 90
sleep 100
sleep 135
sleep 175
sleep 200
sleep 225
...
...
sleep 4100
sleep 4250
would be:
sleep_amout := 1000
sleep, sleep_amout/30.3333333333
sleep, sleep_amout/25
sleep, sleep_amout/16.6666666666
sleep, sleep_amout/11.1111111111
sleep, sleep_amout/10
sleep, sleep_amout/7.40740740740
....
...
...
Would take some hours to do the Math for every single one of those..
Thing is, I have very small, specific and different timings..
example:
sleep 30
sleep 40
sleep 60
sleep 90
sleep 100
sleep 135
sleep 175
sleep 200
sleep 225
...
...
sleep 4100
sleep 4250
would be:
sleep_amout := 1000
sleep, sleep_amout/30.3333333333
sleep, sleep_amout/25
sleep, sleep_amout/16.6666666666
sleep, sleep_amout/11.1111111111
sleep, sleep_amout/10
sleep, sleep_amout/7.40740740740
....
...
...
Would take some hours to do the Math for every single one of those..
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: Possible to change all sleep timings?
Code: Select all
Speed := 0.5
var := "
(
sleep 30
sleep 40
msgbox action
sleep 60
sleep 90
sleep 100
)"
loop, parse, var, `n, `r
new .= (A_LoopField ~= "^sleep") ? (A_LoopField . "*speed`n") : (A_LoopField . "`n")
msgbox %new%
Courses on AutoHotkey
My Autohotkey Blog
Re: Possible to change all sleep timings?
Hi, try his if you want to change all by the same factor as stated in your 1st post.
This will mult all sleep timings by value in var multiplier.
Use your editor to replace "sleep," with "sleep, multiplier *" NO QUOTES Most let you just keep clicking replace so you can check each is the right one.
You'll get this in script ---> sleep, multiplier * (value determined by a check box)
You can change them all at once, but all by same factor
For test. Be aware that due to the granularity of the OS's time-keeping system Sleep is far from accurate.
hunter99
Edited: Sorry, forgot you were going to use a check box to change value, and I didn't use a var.
Edited2: I'm losing it, reread Blackholyman's 2nd post He answered all.
This will mult all sleep timings by value in var multiplier.
Use your editor to replace "sleep," with "sleep, multiplier *" NO QUOTES Most let you just keep clicking replace so you can check each is the right one.
You'll get this in script ---> sleep, multiplier * (value determined by a check box)
You can change them all at once, but all by same factor
For test. Be aware that due to the granularity of the OS's time-keeping system Sleep is far from accurate.
Code: Select all
^t:: ;change var based on your check box, here I used .5 for half speed
multiplier := .5 ;put this in script to load a value for var based on check box.
sleep, multiplier * 10000 ;here for test, I mult by .5 to give half time of 5 sec.
msgbox,,, sleep is over
return
Edited: Sorry, forgot you were going to use a check box to change value, and I didn't use a var.
Edited2: I'm losing it, reread Blackholyman's 2nd post He answered all.
Who is online
Users browsing this forum: arrondark and 359 guests