AutoHotkey Scripting: Reserved keywords

Reserved keywords AutoHotkey

Now it is time for Reserved keywords

So far, we have covered an important concept called variables.

We discussed how to use the operator := to specify values.

We also looked at what to name the variables.

Like True and False are the names of two built-in variables.

There are many other keywords supported

By AHK which are reserved and used for a different purpose.

Every programming languages provides

Their own set of reserved keywords

But there is one important &

Common rule in all the programming languages and it is

We cannot use a reserved keyword to name our variables

Which means in AHK we cannot name our variable things like a_temp or A_scriptdir

Rather reserved keywords can only be used to specify, call or get a build-in function, command, or variable.

 

Reserved keywords example:

If you try to use any reserved keyword for the purpose of variable name, then you will get a syntax error.

 

When you run the above script, it produces the following error −

……

C:\tester.ahk (1) : ==> Not allowed as an output variable.

Specifically: A_AhkPath

……

 

Let’s now give a proper / allowed name to our variable, then the above script should work and execute successfully −

 

That script will not give out any error and will simply work and show you the Msgbox with the value of count

 

Reserved Keywords in AutoHotkey

As an example here is a table having almost all the reserved variable names in Autohotkey – ( there are also function names and commands )

a_ahkpatha_ahkversiona_appdatacommona_appdata
a_autotrima_batchlinesa_caretya_caretx
a_computernamea_controldelaya_dda_cursor
a_ddda_dddda_desktopa_defaultmousespeed
a_desktopcommona_detecthiddentexta_endchara_detecthiddenwindows
a_eventinfoa_exitreason
a_formatfloata_formatintegera_guieventa_gui
a_guicontrola_guicontroleventa_guiheight
a_guiwidtha_guixa_houra_guiy
a_iconfilea_iconhiddena_icontipa_iconnumber
a_indexa_ipaddress1
a_ipaddress2a_ipaddress3a_isadmina_ipaddress4
a_iscompileda_issuspendeda_languagea_keydelay
a_iscriticala_isunicodeerrorlevela_ptrsize
a_lasterrora_linefilea_loopfielda_linenumber
a_loopfileattriba_loopfiledira_loopfileext
a_loopfileshortnamea_loopfileshortpatha_loopregsubkeya_loopfiletimecreated
a_loopfileshortpatha_loopfilefullpatha_loopfilenamea_loopfilelongpath
a_loopfilesizea_loopfilesizekba_loopfiletimeaccesseda_loopfilesizemb
a_loopfiletimemodifieda_loopreadlinea_loopregnamea_loopregkey
a_loopregtimemodifieda_loopregtypea_mina_mday
a_mma_mmma_mona_mmmm
a_mousedelaya_msec
a_mydocumentsa_nowa_numbatchlinesa_nowutc
a_ostypea_osversiona_programfilesa_priorhotkey
a_programsa_programscommona_screenwidtha_screenheight
a_scriptdira_scriptfullpatha_scriptname
a_seca_spacea_startmenucommona_startmenu
a_startupa_startupcommona_taba_stringcasesense
a_thishotkeya_thismenua_thismenuitemposa_thismenuitem
a_tickcounta_timeidlea_timeidlephysical
a_timesincepriorhotkeya_timesincethishotkeya_titlematchmodespeeda_titlematchmode
a_wdaya_windelaya_workingdira_windir
a_ydaya_yeara_yyyya_yweek
clipboardclipboardallcomspec
a_ispauseda_thisfunca_thislabelprogramfiles
a_tempa_usernameFALSETRUE

Now memorize:

I know you cannot memorize all these names 🙂

But as you see many of them start with (a_)

So keep away from using that in your own variable names

Also I listed them down for your reference

And to Show/Explain the concept of reserved keywords

And there are most likely more then the ones I posted here.

So just be mindful while giving a name to your variable

You should not use any of the above mentioned reserved ones.

AutoHotkey does not really have any official best practices when it comes to anything like a naming convention!

Many users do however:

Take a stand in things like this

And at least a few things do come up again and again

When looking at most AHK code

Examples of things like that is:

Indention, camelCase and using “saying” names when making variables or functions.

Your also welcome to read my take/thoughts on some best practices in AutoHotkey

The online AutoHotkey forum is always a good place to get help if you see errors or issues with things like:

  • Not allowed as an output variable.
  • Variable name contains an illegal character
  • Line does not contain a recognized action.

And many others

Please use the comments or my contact form if you need help with this or have something to add

jszadmin

Drafter and Webmaster at JSZapp.com
I’m Jackie Sztuk or JSZ. I have a Drafter’s degree from Copenhagen Technical College (KTS) and my passion for windows scripting is what makes me want to help as meny as i can by writing great and easy to follow How-to's.

jszadmin

I’m Jackie Sztuk or JSZ. I have a Drafter’s degree from Copenhagen Technical College (KTS) and my passion for windows scripting is what makes me want to help as meny as i can by writing great and easy to follow How-to's.

Leave a Reply