.exe or .ahk for Windows autostart?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Fraka
Posts: 11
Joined: 17 Feb 2017, 04:46

.exe or .ahk for Windows autostart?

Post by Fraka » 12 Oct 2021, 03:26

Hi!

What's faster / has less memory impact?
I don't know about the processes behind it.

When loading 4 little scripts at startup, I imagine .ahk being better as only one service worker has to be started for running the ahk scripts.
.exe is precompiled but needs a service worker each?

Best regards,
Fraka

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: .exe or .ahk for Windows autostart?

Post by mikeyww » 12 Oct 2021, 05:29

You can find the answer. Test each approach. Time them. Check Windows Task Manager for memory usage. You can then compare quickly. Within a script, A_TickCount can also be used to compute elapsed time.

Fraka
Posts: 11
Joined: 17 Feb 2017, 04:46

Re: .exe or .ahk for Windows autostart?

Post by Fraka » 13 Oct 2021, 05:08

Thank you for your answer.

Well it's beyond my skills so I was asking.

Thanks to your guidance I can now see that the .exe have a ~10x bigger memory impact, but I don't know so many things. Maybe the .ahk use a service / other .exe in the background that shoots the usage well beyond the many-exes-approach. "runtimebroker.exe", "svchost.exe", ...?

Timing is a problem. I don't know how to do it. And I don't expect huge differences on my laptop. But it would be nice to know a best practice as I use scripts not only on my machines and want to have a small as possible impact.
I thought about putting 100 ahks and in another approach 100 exes into autostart, but it is hard for me to say when to start and when to stop the timer.

The A_TickCount only measures the script action itself, not the startup.

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: .exe or .ahk for Windows autostart?

Post by mikeyww » 13 Oct 2021, 06:11

Approach #1. OK. As I noted via my link, the A_TickCount reports the number of milliseconds that have elapsed since the system was started. Perhaps this is useful to you in your startup script. If you run a script that displays this value, you will see the exact time from startup to that moment.

Approach #2. I was thinking that you are interested in this because of the impact on you as a person-- the user of your computer. If that is the case, then it seems to me that you could just use a stopwatch, and see what happens with the two approaches. You can start it when you turn on your computer. You could run the test ten times, take the average, and compare.

Code: Select all

MsgBox, 64, Seconds since startup, % Round(A_TickCount / 1000)

Fraka
Posts: 11
Joined: 17 Feb 2017, 04:46

Re: .exe or .ahk for Windows autostart?

Post by Fraka » 20 Oct 2021, 11:39

Thank you again.
Short answer after my unscientific tests: using .ahk is always better. Use .exe only if you don't want to install AutoHotKey or need it portable. Overall the impact on a modern PC is negligible.

lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: .exe or .ahk for Windows autostart?

Post by lexikos » 22 Oct 2021, 03:50

Compiling a script combines the script's text and the interpreter into one file, hiding the script's text from casual inspection and making it slightly more portable by virtue of the fact that there is one file instead of multiple.

It is not necessary to compile each script just to avoid installing AutoHotkey. There are multiple ways to use AutoHotkey.exe to run scripts without installing anything.

Regarding memory usage, running multiple processes from the same executable file is generally more efficient than running multiple copies of the executable file, whether or not each copy is slightly different (as with compiled scripts) or the same. This is due to OS memory management behaviour.

There is no such thing as an AutoHotkey "service worker", and AutoHotkey does not run as a Windows service. When you "run" a script file, it executes in a single AutoHotkey process, just as "opening" a text file executes a single Notepad process.

Post Reply

Return to “Ask for Help (v1)”