I have written a script that should answer your question. Each 10 milliseconds, we get the position of the mouse. If it was on the edge and has now moved off of it, we count that as a "tap" and start a 1 second timer (1000 milliseconds, the actual argument in the code is negative since we want it to run only once). Each tap also increments taps
by one, so we can keep track of how many taps there are. At the end of the 1 second timer, we see if the user has tapped the edge of the screen twice. If so, send the Alt-F4 keystroke!
;; 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