根据鼠标位置触发AHK脚本
Trigger AHK script based on the position of the mouse
是否可以根据鼠标位置触发AHK脚本?比如说,如果我将鼠标移到屏幕的角落或边缘,我想按下键盘上的一个按钮或一系列按钮。另外,是否可以每秒多次执行此操作,直到鼠标移出指定区域?
当我想做相反的事情时,我只能通过谷歌搜索找到使用键盘移动鼠标的 AHK 脚本。
是的。我能想到的最简单的方法是使用 SetTimer and MouseGetPos 来评估位置,如果匹配则触发脚本。
MouseGetPos 上的第二个示例代码正在使用 SetTimer。这应该让你朝着正确的方向前进。
我做到了,谢谢 Aaron 和 ahkcoder。
我对 Up
和 Down
的感觉比 PgUp
和 PgDn
好一点,对其他人来说,玩玩时间直到它足够。您还需要修改屏幕边缘的值。
; move up and down when mouse is at edges of screen
#Persistent
SetTimer, foo, 65
return
foo:
MouseGetPos, x, y, id, control
; ToolTip, %x% %y%
; will trigger only at edges of a full screen
if (y = 1087){
; bottom
send {Down}
send {Down}
send {Down}
; sleep, 300
}
else if(y = 8){
; top
send {Up}
send {Up}
send {Up}
}
return
是否可以根据鼠标位置触发AHK脚本?比如说,如果我将鼠标移到屏幕的角落或边缘,我想按下键盘上的一个按钮或一系列按钮。另外,是否可以每秒多次执行此操作,直到鼠标移出指定区域?
当我想做相反的事情时,我只能通过谷歌搜索找到使用键盘移动鼠标的 AHK 脚本。
是的。我能想到的最简单的方法是使用 SetTimer and MouseGetPos 来评估位置,如果匹配则触发脚本。
MouseGetPos 上的第二个示例代码正在使用 SetTimer。这应该让你朝着正确的方向前进。
我做到了,谢谢 Aaron 和 ahkcoder。
我对 Up
和 Down
的感觉比 PgUp
和 PgDn
好一点,对其他人来说,玩玩时间直到它足够。您还需要修改屏幕边缘的值。
; move up and down when mouse is at edges of screen
#Persistent
SetTimer, foo, 65
return
foo:
MouseGetPos, x, y, id, control
; ToolTip, %x% %y%
; will trigger only at edges of a full screen
if (y = 1087){
; bottom
send {Down}
send {Down}
send {Down}
; sleep, 300
}
else if(y = 8){
; top
send {Up}
send {Up}
send {Up}
}
return