我写了一个应该回答你的问题的脚本。每10毫秒,我们就得到鼠标的位置。如果它处于边缘并且现在已经离开它,我们将其计为“轻敲”并启动1秒计时器(1000毫秒,因为我们只希望它只运行一次,代码中的实际参数为负数)。每个水龙头也会将taps
增加1,因此我们可以跟踪有多少水龙头。在1秒计时器结束时,我们看到用户是否敲击了屏幕边缘两次。如果是这样,请发送Alt-F4按键!
;; by default ahk gets mouse coordinates relative to the active
;; window, this sets it to use absolute coordinates
CoordMode, Mouse, Screen
;; how often to get the mouse position in milliseconds
UPDATE_INTERVAL := 10
RIGHT_EDGE := A_ScreenWidth - 1
;; make the script run forever
#Persistent
SetTimer, WatchCursor, %UPDATE_INTERVAL%
return
WatchCursor:
MouseGetPos, xpos
;; a tap is defined by touching and leaving the edge,
;; we don't want to count holding the mouse at the edge
;; as a tap
if (prev = RIGHT_EDGE && xpos != RIGHT_EDGE) {
taps += 1
; negative time means run once
SetTimer, EdgeTimer, -1000
}
prev := xpos
return
EdgeTimer:
;; more than 2 taps are ignored
if (taps = 2) {
Send !{F4}
}
taps := 0
return
是的,它可以在AHK中实现。您可以使用频繁运行的循环/定时器,并将当前光标位置与相应的窗口边缘进行比较。但是,此算法与您发布的代码无关,因为您无法用热键代表“鼠标悬停事件”。更重要的是,我怀疑这个鼠标手势的本质是非常容易出错的。如果用户穿过右边框,然后返回窗口(例如,关闭右窗口时)会发生什么?一般来说,你想达到什么目的? – MCL