autohotkey - 我如何使用 AutoHotkeys 的相对路径

标签 autohotkey

我正在尝试在 AutoHotKeys 中使用相对路径,以便可以 check out 源代码管理并且热键仍然有效。

使用 %A_WorkingDir% 给我脚本的位置。从那里我需要向上移动一个目录并向下导航到我需要运行的脚本。

我试过:

^!a::
    Path = %A_WorkingDir%
    Run %Path%\..\locationOf\script.cmd

^!a::
    Path = %A_WorkingDir%\..
    Run %Path%\locationOf\script.cmd

^!a::
    Path = %A_WorkingDir% \..
    Run %Path%\locationOf\script.cmd

^!a::
    Path = %A_WorkingDir% "\.." ; Also removed the space between % and " -> %A_WorkingDir%"\.." but didn't work
    Run %Path%\locationOf\script.cmd

除非没有其他办法,否则我真的不想对工作目录进行任何字符串操作来强制执行它?

谢谢你的帮助

最佳答案

试试
运行 %A_WorkingDir%\..\locationOf\script.cmd
或者
运行“%A_WorkingDir%\..\locationOf\script.cmd”
或者
运行 %comspec%/k "%A_WorkingDir%\..\locationOf\script.cmd"


正如 BGM 所说:

Keep in mind that the workingdir can also be changed via a windows launcher or shortcut. If you use a launcher like JetToolbar (my favourite) it sets the workingdir to its own application directory by default. It might be a good idea for the script to set the workingdir to the scriptdir or just use scriptdir instead.

解决方案:
SetWorkingDir, %A_ScriptDir%

关于autohotkey - 我如何使用 AutoHotkeys 的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22468224/

相关文章:

git - 如何通过 Autohotkey 读取 Git Bash 中命令的输出

spotify - 如何在最小化时使用 Autohotkey 为 Spotify 歌曲加注星标?

autohotkey - 傻瓜键盘 Hook

loops - AutoHotKey 击键中断循环

amazon-web-services - 有什么方法可以使用代码或脚本在全屏 View 中在本地桌面和 AWS Workspace 之间切换?

expression - Autohotkey 单行代码?

c++ 我应该在这个 dll 脚本中使用什么类型?

emacs - 在 Windows 上的 Emacs 中将 Caps Lock 映射到 Control

sublimetext - 用于切换 Sublime Text 3 侧边栏的 AutoHotkey 脚本还是有原生 ST 设置?

properties - AutoHotkey 字符串与对象属性连接