This is the original script:
Code: Select all
#SingleInstance, Force
actionDelay := 10
; if the mouse is at the given edge of the screen
; and at the same time, the mouse doesn't leave that edge
; during the process of waiting, after how many ms do we trigger
; an action?
;
refreshRate := 100
; after how many ms we reread the position of the mouse
oldMon := "", oldEdge := "", Count := 0
Loop,
{
MouseIsOnEdgeOfMon(mon, edge)
; first condition - mouse is on edge
if(edge != "none")
{
; remember the edge
oldMon := mon, oldEdge := edge
}
else ; if edge = "none"
{
; reset the edge memory
oldMon := "", oldEdge := ""
}
; if mouse still on the same edge, increase the counter
if(mon = oldMon && edge = oldEdge)
{
; increase the counter
Count++
}
else ; if the mouse on a different edge
{
Count := 0 ; reset the counter
oldMon := mon, oldEdge := mon ; reset the data about the previous edge
actionInvoked := false ; reset the trigger info for the new edge
}
; second condition - mouse is still on the _same_ edge
; a given amount of time has elapsed
if(mon = oldMon && edge = oldEdge && Count*refreshRate > actionDelay)
{
; third condition - the mouse stayed on a particular edge
; the whole time, _and_ the action was not yet called for this edge
if(actionInvoked = false)
{
actionAllowedToRun := true
}
else
{
actionAllowedToRun := false
}
}
else ; delay time not sufficient
{
; do nothing - just wait
}
; trigger the action
if(actionAllowedToRun = true) {
if (mon = 1 && edge = "Left") {
;Send, {Your Key}
}else if(mon = 1 && edge = "Right") {
;Send, {Your Key}
}else if(mon = 1 && edge = "Top") {
;Send, {Your Key}
}else if(mon = 1 && edge = "Bottom") {
;Send, {Your Key}
}else if(mon = 2 && edge = "Left") {
}else if(mon = 2 && edge = "Right") {
}else if(mon = 2 && edge = "Top") {
}else if(mon = 2 && edge = "Bottom") {
}
actionInvoked := true
actionAllowedToRun := false
}
Sleep , % refreshRate
}
return
MouseIsOnEdgeOfMon(ByRef mon, ByRef edge, PixOffset = 5) {
; settings
static SM_CMONITORS := 80
CoordMode, Mouse, Screen
SysGet, monCount, % SM_CMONITORS
Loop, % monCount
SysGet, mon%A_Index%, Monitor, %A_Index%
MouseGetPos, x, y ; relative to primary monitor
Loop, % monCount
{
i := A_Index
; top edge
if( mon%i%Left <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= (mon%i%Top + PixOffset) )
return, 1, ErrorLevel := 0, mon := i, edge := "Top"
; bottom edge
else if(mon%i%Left <= x && x <= mon%i%Right)
&& ( (mon%i%Bottom - PixOffset) <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Bottom"
; left edge
else if(mon%i%Left <= x && x <= (mon%i%Left + PixOffset) )
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Left"
; right edge
else if( (mon%i%Right - PixOffset) <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Right"
; no edge
else if(mon%i%Left <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 0, ErrorLevel := 0, mon := i, edge := "none"
}
return, "", ErrorLevel := 1 ; shouldn't happen
}
This is the script that i tried with SetTitleMatch 2
Code: Select all
#SingleInstance, Force
actionDelay := 10
; if the mouse is at the given edge of the screen
; and at the same time, the mouse doesn't leave that edge
; during the process of waiting, after how many ms do we trigger
; an action?
;
refreshRate := 100
; after how many ms we reread the position of the mouse
oldMon := "", oldEdge := "", Count := 0
Loop,
{
MouseIsOnEdgeOfMon(mon, edge)
; first condition - mouse is on edge
if(edge != "none")
{
; remember the edge
oldMon := mon, oldEdge := edge
}
else ; if edge = "none"
{
; reset the edge memory
oldMon := "", oldEdge := ""
}
; if mouse still on the same edge, increase the counter
if(mon = oldMon && edge = oldEdge)
{
; increase the counter
Count++
}
else ; if the mouse on a different edge
{
Count := 0 ; reset the counter
oldMon := mon, oldEdge := mon ; reset the data about the previous edge
actionInvoked := false ; reset the trigger info for the new edge
}
; second condition - mouse is still on the _same_ edge
; a given amount of time has elapsed
if(mon = oldMon && edge = oldEdge && Count*refreshRate > actionDelay)
{
; third condition - the mouse stayed on a particular edge
; the whole time, _and_ the action was not yet called for this edge
if(actionInvoked = false)
{
actionAllowedToRun := true
}
else
{
actionAllowedToRun := false
}
}
else ; delay time not sufficient
{
; do nothing - just wait
}
; trigger the action
if(actionAllowedToRun = true) {
if (mon = 1 && edge = "Left") {
;Send, {Your Key}
}else if(mon = 1 && edge = "Right") {
SetTitleMatchMode 2
#IfWinActive, Firefox
Send {Your Key}
#IfWinActive
}else if(mon = 1 && edge = "Top") {
;Send, {Your Key}
}else if(mon = 1 && edge = "Bottom") {
;Send, {Your Key}
}else if(mon = 2 && edge = "Left") {
}else if(mon = 2 && edge = "Right") {
}else if(mon = 2 && edge = "Top") {
}else if(mon = 2 && edge = "Bottom") {
}
actionInvoked := true
actionAllowedToRun := false
}
Sleep , % refreshRate
}
return
MouseIsOnEdgeOfMon(ByRef mon, ByRef edge, PixOffset = 5) {
; settings
static SM_CMONITORS := 80
CoordMode, Mouse, Screen
SysGet, monCount, % SM_CMONITORS
Loop, % monCount
SysGet, mon%A_Index%, Monitor, %A_Index%
MouseGetPos, x, y ; relative to primary monitor
Loop, % monCount
{
i := A_Index
; top edge
if( mon%i%Left <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= (mon%i%Top + PixOffset) )
return, 1, ErrorLevel := 0, mon := i, edge := "Top"
; bottom edge
else if(mon%i%Left <= x && x <= mon%i%Right)
&& ( (mon%i%Bottom - PixOffset) <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Bottom"
; left edge
else if(mon%i%Left <= x && x <= (mon%i%Left + PixOffset) )
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Left"
; right edge
else if( (mon%i%Right - PixOffset) <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 1, ErrorLevel := 0, mon := i, edge := "Right"
; no edge
else if(mon%i%Left <= x && x <= mon%i%Right)
&& (mon%i%Top <= y && y <= mon%i%Bottom)
return, 0, ErrorLevel := 0, mon := i, edge := "none"
}
return, "", ErrorLevel := 1 ; shouldn't happen
}