如何在 AutoHotkey 中检索当前脚本的文件名?

How do I retrieve the filename of the current script in AutoHotkey?

我想在 AutoHotkey 中检索当前 运行 脚本的文件名并将其保存到一个变量中。

例如,如果我的脚本名为 sample-script.ahk,我想显示一条消息说“当前脚本是 sample-script.ahk” .

如何在 AutoHotkey 中检索当前活动脚本的文件名?

使用:A_ScriptName 当前脚本的文件名,不带路径,例如MyScript.ahk.

MsgBox, The current script is %A_ScriptName%

参见:https://autohotkey.com/docs/Variables.htm#BuiltIn

更具体地说,https://autohotkey.com/docs/Variables.htm#ScriptName