是否可以在 AHK 中同时触发 2 个热键?

Is it possible to trigger 2 hotkeys simultaneously in AHK?

我正在尝试用键盘模拟鼠标移动。我可以一次在 xy 平面上移动一个方向,但现在我需要对角线移动,例如按住 shift + w + d 向上移动。我更喜欢可以解决一般同时触发多个热键问题的答案,因为这是我想在其他脚本中实现的东西。

#NoEnv
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
#NoTrayIcon
SendMode Input
SetDefaultMouseSpeed, 0

;Variables
taskbar_height := 630
effective_screen_height := A_ScreenHeight - taskbar_height
x_movement := 0.03*A_ScreenWidth
y_movement := 0.05*effective_screen_height

;Mouse
+a::MouseMove, -%x_movement%, 0,, R
+d::MouseMove, %x_movement%, 0,, R
+w::MouseMove, 0, -%y_movement%,, R
+s::MouseMove, 0, %y_movement%,, R

(标准)AutoHotkey does not support multi-threading, but you can use things like SetTimer and other shenanigans for "fake multithreading" (some examples here).

然而,对于这种特定情况,最好有一个循环来检查关键键(Shift、w、a、s 和 d)的哪些组合被按下并根据该组合采取适当的行动.

注意:AutoHotkey_H 存在并为香草 AHK 提供多线程功能,如果您对该方法感兴趣,还提供一些其他功能。