有没有办法告诉自动热键操作(子程序)释放Alt
按键,尽管它的触发器是什么Alt + X
?这是我的代码...
!x::
sleep 100
it does some clicks and drags here (work fine)
return
但是尽管sleep 100
在我的代码中,有时当我按下时,Alt + X
如果我手动让 alt 按下,脚本将执行一个Alt Click
,而不是仅仅一个Click
执行完全不同的事情。
我知道我可以增加延迟(睡眠 100),或者将 AHK 设置为等到释放 alt 键,但这些都无济于事,因为该脚本将连续运行多次,所以我更喜欢按住Alt
并按下/向上x
几次以便连续运行它多次。
所以我需要一种方法来暂时阻止键盘,或者设置脚本来释放 alt 键,这样 autohotkey 就不会识别出我的手指Alt
在执行脚本几次时仍在按下该键。
我需要类似的东西......
BlockInput, MouseMove
BlockInput, On
顺便说一句,我已经尝试了这两种方法,但它们都没有用。
编辑>>>>>
这是我单击并拖动的功能......
AR4clickDnABmoveClickUpCDfn(ParamA, ParamB, ParamC, ParamD)
{
If AR4togWorkbMode
{
AR4workbModeFn() ; Since this fn is used to click n drag panels, after disabling AR4workbMode I won't enable it back, cuz is supposed I need to see the Panel I'm draging afterward
AR4togWorkbMode := !AR4togWorkbMode ; So AR4retWorkbMode doesn't need to be set, but AR4togWorkbMode does
Sleep 200
}
MouseGetPos X, Y
BlockInput, On
; BlockInput, MouseMove
Sleep 50
MouseMove, ParamA, ParamB
Click down
Sleep 50
Loop 10
{
MouseMove, -1, 1, 100, R
}
Sleep 40
MouseMove, ParamC, ParamD, 100
Click Up
BlockInput, Off
; BlockInput, MouseMoveOff
MouseMove %X%, %Y%
}
然后我在其他子程序中!x
运行一个子程序,该子程序将单击一个面板并调用该click and drag
函数,以便拖动面板,就是这样..
#If WinActive("ahk_class ArtRage 3") or WinActive("ahk_class ToolWindow")
<!x::
; Lalt & x::
If !AR4togToolSetsNear ; will run the first time the hotkey is pressed cuz the toggle var is not set yet
{
Sleep 220
AR4clickDnABmoveClickUpCDfn(AR4toolSetsX0 + AR4toolSetsSetGapXX, AR4toolSetsY0 + 10, AR4toolSetsNearX, AR4toolSetsNearY)
AR4togToolSetsNear := !AR4togToolSetsNear
Sleep 20
WinActivate, ahk_class ArtRage 3
}
Else
{
Sleep 220
AR4clickDnABmoveClickUpCDfn(AR4toolSetsNearX, AR4toolSetsNearY, AR4toolSetsX0 + AR4toolSetsFarDifXX, AR4toolSetsY0 + AR4toolSetsFarDifYY)
AR4togToolSetsNear := !AR4togToolSetsNear
Sleep 20
WinActivate, ahk_class ArtRage 3
}
Return
#If
但是,由于此子程序触发器包含Lalt
如果我按下并按住,Alt
同时按下和释放X
多次以多次调用子程序。 然后 AHK 脚本将发送Alt Click and Drag
,不仅Click and Drag
前者会实际旋转面板,而后者会移动它,我想移动它,而不是旋转它,但另一方面我需要按住 ALT 才能多次运行子程序,我该怎么办??
当我手动按下 Alt 键盘时,如何让 AHK 将 Alt 键盘视为释放?
希望一些超级用户可以帮助我,提前谢谢。
答案1
; Trigger an action (subroutine) by releasing the left Alt key,
; without losing its native function as modifier key:
LAlt up::
if (A_PriorKey = "LAlt")
Send a ; do sth
return
; Trigger another action by releasing the left Alt key
; in a key combination:
LAlt & x:: Send b ; do sth else
; or:
; <!x:: Send b ; <! means LAlt
答案2
下面是一个如何使用 blockinput 的示例
https://autohotkey.com/docs/commands/BlockInput.htm
^!p::
KeyWait Control ; Wait for the key to be released. Use one KeyWait for each of the hotkey's modifiers.
KeyWait Alt
BlockInput On
; ... send keystrokes and mouse clicks ...
BlockInput Off
return
我只需要添加 KeyWait Alt