Which SetBatchLines precautions ?

Get help with using AutoHotkey and its commands and hotkeys
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Which SetBatchLines precautions ?

20 Mar 2018, 12:33

Hi everyone,

I'm currently having a hard time to see which precautions should be taken when using to maximize a script speed:

Code: Select all

SetBatchLines, -1
Indeed I'm wondering if in some cases that might not cause some crashes.

I'm using it for example in creating a GUI that display a ListView with a list of files quite similar to the ListView Main example from the documentation:
https://autohotkey.com/docs/commands/Li ... m#Examples
To maximize speed looping through the files, checking some stuff, and displaying the ListView I used "SetBatchLines, -1" at the top.
However I have sometimes crashes when launching the GUI. The script becomes unresponsive before the GUI shows up and there is nothing I can do except killing the process via task manager.
Spoiler
I saw on several occasions that it was mentioned that when using "SetBatchLines, -1" you should put manual sleeps at some places.
It was mentioned loops but I couldn't understand in which loop you should introduce the sleep.

So could someone tell me if SetBatchLines, -1 is suceptible to crash AutoHotkey with some particular commands, especially in a loop?
And if yes what should be done to prevent it while maximizing speed? Which loops can be problematic?

As sensitive commands/functions inside the script I was wondering if they can be a problem with SetBatchLines,-1 ?:
Spoiler
Thanks for your enlighment on this subject ! ;)
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: Which SetBatchLines precautions ?

20 Mar 2018, 14:05

So could someone tell me if SetBatchLines, -1 is suceptible to crash AutoHotkey with some particular commands, especially in a loop?
No, it isn't.

Setbatchlines only causes sleeps in between lines, not during any command execution. You could have timing-bugs which only appears when using setbatchlines, but setbatchlines wouldn't be the root cause.
wolf_II
Posts: 2269
Joined: 08 Feb 2015, 20:55

Re: Which SetBatchLines precautions ?

20 Mar 2018, 16:10

Are you regarding "crashes" the same as "unresponsive"?
You can do something to resolve unresponsiveness caused by speeding up.
If you want to control how AHK is using its time-slice, you also should control where AHK allows OS and other programs to run.

You just make sure every Loop (For, While, Loop) contains Sleep, -1.
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Re: Which SetBatchLines precautions ?

20 Mar 2018, 19:14

Thanks for answering.

Yes it becomes unresponsive and I cannot do anything but kill it via task manager. But no indeed there is no crash message.

So why should every loop contain "Sleep, -1" ?

It can be a pain to add for every loop because I have many.
It is especially difficult as the SetBatchLines take effet on the whole thread if I got it right (meaning adding sleep -1 to every loop inside the functions it is calling as well)
Shouldn't it be only in long long loops to be sure incoming messages are processed? What's the reason behind it?

Anyway in the meantime I've taken on the difficult part to re-write in a much cleaner way this part of my program to see if the issue disappear.
Could be due to something else indeed, I can't be sure.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], malcev, newbieforever and 43 guests