尽管它在启动文件夹中,但必须重新加载 AHK 脚本

问题描述

我有一个 AHK 脚本,可以将我的鼠标中键重新映射到 Delete 键。我已将此脚本与其他脚本一起添加shell:startup 找到的启动文件夹中。但是,即使在启动时自动加载该脚本,该脚本也无法正常工作。为了使它工作,我再次需要通过在系统托盘中右键单击脚本图标时选择 Reload this script 选项来重新加载它。只有在重新加载脚本后,映射才能正常工作。我可以更改什么才能使脚本在第一次加载时像所有其他脚本一样工作?

这是脚本本身(足够简单......)

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

MButton::Delete

解决方法

@Iww 成功回答了评论中的问题。

问题是 shell:startup 目录中的 autohotkey 脚本快捷方式过多。将每个脚本作为 #Include [directory][script].ahk 放入一个主脚本中,并在 shell:startup 中只放置 main 的快捷方式即可。