SetBatchLines without effect? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

SetBatchLines without effect?

13 Feb 2018, 03:31

Hi,

i always thought that with setbatchlines you can cause a delay after each line of script. If you execute the script below, i would have assumed that it would take 3 seconds for the next msgbox to appear. But this is not the case. Does anybody know why?
(I didn't want to use the Sleep command)

Code: Select all

setbatchlines, 3000ms

msgbox,4096,, %A_BatchLines%
msgbox,4096,, 1
msgbox,4096,, 2
msgbox,4096,, 3
msgbox,4096,, 4
msgbox,4096,, 5
msgbox,4096,, 6
return
pneumatic
Posts: 338
Joined: 05 Dec 2016, 01:51

Re: SetBatchLines without effect?

13 Feb 2018, 05:19

setbatchlines, 3000ms means that it will sleep for 10ms every time it has run for 3 seconds , and those few lines of code dont take 3 seconds , so it never sleeps.

https://autohotkey.com/docs/commands/SetBatchLines.htm

It seems you should use linecount as the second parameter instead.

edit: but that won't get you what you want (a 3 second sleep between each line). So if you want to achieve that without sleep, it seems the only other way would be to use a timer , maybe something like this

Code: Select all

#Persistent
SetTimer, ShowMessageBox, 1000
return

ShowMessageBox:
((!counter) or (counter>=6)) ? (counter:=1) : (counter+=1)
;if counter is blank or >=6, reset the counter to 1, else increment it by 1

If (counter = 1)
	msgbox,4096,, 1
If (counter = 2)
	msgbox,4096,, 2
If (counter = 3)
	msgbox,4096,, 3
If (counter = 4)
	msgbox,4096,, 4
If (counter = 5)
	msgbox,4096,, 5
If (counter = 6)
	msgbox,4096,, 6

return
Guest

Re: SetBatchLines without effect?

13 Feb 2018, 07:11

Thank you for the clarification and your suggestion.

The reason for my question was because I have a lot of large scripts and many users would like to see in a kind of test mode what happens in detail during the execution.

So my idea was to give the user the possibility to slow down the scripts without rewriting them all.

Is there perhaps a command (e.g. some kind of OnMessage()...) that calls automatically a function after executing one line of the script? :roll:
(The called funktion could have only one line with a Sleep command)

BR Andreas
pneumatic
Posts: 338
Joined: 05 Dec 2016, 01:51

Re: SetBatchLines without effect?

13 Feb 2018, 10:40

I think you might need to call a windows function with DllCall to change the process's time slice length.

There is also the command Listlines which your users could trigger with a hotkey at any time to see what the last lines of code were up to that point.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: SetBatchLines without effect?  Topic is solved

13 Feb 2018, 18:46

You're essentially looking for a step-through option, correct? I believe AHK Studio has that feature.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 246 guests