How long can script be and how many can I use? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sulphuricsaliva
Posts: 48
Joined: 11 Sep 2018, 12:37

How long can script be and how many can I use?

15 Mar 2022, 09:58

Hello, I've been adding stuff to my script for a few years now and it has come to a point that I've split it in two because some things stopped working. Even so, I have a third one, which is just like an autocorrect that recently began malfunctioning too, and splitting it doesn't solve the problem.
It seems like sometimes they work, sometimes they don't and I can't figure out if the scripts have too many lines or if having 3 or more scripts running at the same time causes any issues.
Example of the dictionary one:

Code: Select all

::aniversario::aniversário
::aniversarios::aniversários
::amnesia::amnésia
::amnesias::amnésias
::anonimo::anónimo
::anonimos::anónimos
::antecedencia::antecedência
::antecedencias::antecedências
::antecipaçao::antecipação
::antipatico::antipático
::antipaticos::antipáticos
::antipatica::antipática
::antipaticas::antipáticas
::anus::ânus
[Mod edit: [code][/code] tags added.]

It goes on for 7000 lines or so but the others are relatively short.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How long can script be and how mant can I use?

15 Mar 2022, 10:06

My hunch would be not that the files are too long, but that you have a bug or conflicting scripts. The issue of conflicting scripts is easy to check, because you can just close your other scripts, and retest.

A convenient approach to managing and running a long script that has discrete sections would be #Include. That would let you "concatenate" multiple scripts into one, while maintaining them separately, and running a single script instead of multiple scripts.

Suggestions for follow-up here: I typically find that problem descriptions such as "stopped working", "malfunction", and "sometimes they don't [work]" are insufficient for efficient debugging. What helps is posting (or attaching, if very long) the script, describing what happens when the script runs, and describing what should happen instead.
sulphuricsaliva
Posts: 48
Joined: 11 Sep 2018, 12:37

Re: How long can script be and how mant can I use?

15 Mar 2022, 10:24

Thank you for your answer. I have tried each one separately, let's forget the dictionary script for now and I'll give you a very specific issue that's giving me the biggest headache.

Code: Select all

$*mbutton::
Send {Blind}{mbutton}
KeyWait, mbutton, T0.3
If ErrorLevel {
	Send {Media_Play_Pause}
	KeyWait, mbutton
}
return
[Mod edit: [code][/code] tags added.]

This, for instance, only works if It's not a part of my main script and It's not the only one. I can't figure out why.
Last edited by sulphuricsaliva on 15 Mar 2022, 10:25, edited 1 time in total.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How long can script be and how mant can I use?  Topic is solved

15 Mar 2022, 10:29

A common cause of the problem that you described is failure to attend to the auto-execute section of the script. In your case, however, you have a hotkey that is apparently not triggering. Causes may include an unexpectedly applied context requirement via #If.

One suggestion for debugging is to alter your hotkey routine to the following alone, while you are testing.

Code: Select all

MButton::MsgBox, Fired!
That will enable you to understand whether it is being triggered.
sulphuricsaliva
Posts: 48
Joined: 11 Sep 2018, 12:37

Re: How long can script be and how mant can I use?

15 Mar 2022, 15:52

I've tried it, no messagebox...I did find out, thanks to you that it was my only #if line that was causing it. How do I prevent this from happening?

the if line is:

Code: Select all

#If WinActive("ahk_class CabinetWClass ahk_exe explorer.exe")
Tab::Send, !v!n{Enter}
return
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How long can script be and how many can I use?

15 Mar 2022, 16:08

Put your global hotkeys above those lines instead of below.
sulphuricsaliva
Posts: 48
Joined: 11 Sep 2018, 12:37

Re: How long can script be and how many can I use?

15 Mar 2022, 16:31

Yes that seems to be working right now but I'll probably have trouble when adding another #if. Just wanted to know if this is always supposed to happen with #if. Now I just have to figure out the dictionary thing but you have been very helpful, thank you very much. :clap:
User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: How long can script be and how many can I use?

15 Mar 2022, 17:25

Just to make sure you are aware of this: https://www.autohotkey.com/download/AutoCorrect.ahk

This has ~5,300 entries. Not quite your 7,000 but up there. I have used this for years. No apparent issues. There must be an upper limit (there is to everything!) but 7,000 is not impossible imho.
14.3 & 1.3.7
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How long can script be and how many can I use?

15 Mar 2022, 18:53

#If applies to everything below it. When you add a new #If, the old one no longer applies to the code below it. If you add #If by itself, you return to a global context where the previous #If no longer applies.
Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: How long can script be and how many can I use?

17 Mar 2022, 06:32

Someone need to say, sorry for this....

You spent more time on that dictionary than on a typping program like Klavaro 2.0 (or any other one to learn computer typping).

I recently changed to an ergonomic keyboard, mecanical fingers movements are different from what I was used to for 20 years!!, so I spend 1 month, 1 hour daily to fix it, to learn new key distribution, etc. That must to be done.

Some keyboard layouts are strange (localization keys), AHK can help to change those keys to a better position, for example.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LAPIII, peter_ahk and 334 guests