What syntax for relative paths used in scripts (eg. if driver letter change G to Y the script should keep working)

Discussion, questions and support.
Post Reply
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Jan 21st, ’19, 13:58

Hi,

So far I have been writing scripts in Fastkeys pointing to absolute paths. Example:
"G:\Program\Name\File.exe"

However, as many of my programs are portable and stored in the same drive as FastKeys, I would like to know a syntax that would make the scripts working from any driver. So if the driver is connected as Y ("Y:\Program\Name\File.exe"), the scrip wouldn't break because it is still looking in the absolute path "G:\Program\Name\File.exe".

Just as a reference, I would expect something as "?:\Program\Name\File.exe" or "..\Program\Name\File.exe" etc.

Can I write scripts in Fastkeys using relative paths?

Thank you very much!
Cadu
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 21st, ’19, 14:59

You can use built-in variables like
A_WorkingDir
A_ScriptDir
A_WinDir
A_ProgramFiles
A_AppData
A_MyDocuments
etc...
https://www.autohotkey.com/docs/Variables.htm#prop

../ type syntax should also work.
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Jan 21st, ’19, 15:41

Many thanks Marko!
Post Reply