-
Notifications
You must be signed in to change notification settings - Fork 0
/
CycleMouseMonitors.ahk
125 lines (96 loc) · 2.49 KB
/
CycleMouseMonitors.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
#Persistent
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
;#MaxThreadsPerHotkey 5
Coordmode, Mouse, Screen
;OPTIMIZATIONS START
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
;OPTIMIZATIONS END
Appname := "CycleMouseMonitors"
Version := 1.0
global Appname
global Version
Menu, Tray, Icon, %A_ScriptDir%\CycleMouseMonitors.ico
Menu, Tray, Tip , Cycle Mouse Monitors
Menu, Tray, NoStandard
Menu, Tray, deleteall
Menu, Tray, Add, Opener, opener
Menu, Tray, Default, 1&
;Menu, Tray, Click, 1
Menu, Tray, Rename, 1&
Menu, Tray, Add, Start on Boot, BootMenu
If (CheckStartOnBoot()){
Menu, Tray, Check, Start on Boot
}else{
Menu, Tray, Uncheck, Start on Boot
}
Menu, Tray, Add, Restart , Restart
Menu, Tray, Add, About, About
Menu, Tray, Add, Exit, Exit
Menu, Tray, Click, 1
left := 0
SM_CMONITORS := 80
SysGet, monCount, % SM_CMONITORS
Loop, % monCount
{
SysGet, mon%A_Index%, Monitor, %A_Index%
if ( mon%A_Index%Left <= left )
left := mon%A_Index%Left
if ( mon%A_Index%Right >= right )
right := mon%A_Index%Right
}
; MsgBox, % right left
CoordMode, Mouse, Screen
PixOffset := 2 ; how many pixels we consider an edge of the screen
SetTimer, WatchMouse, 200
}
return
opener:
Menu, Tray, Show
return
CheckStartOnBoot()
{
RegRead, StartupReg, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, %Appname%
return StartupReg
}
BootMenu:
If (CheckStartOnBoot()){
RegDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, %Appname%
Menu, Tray, Uncheck, Start on Boot
}else{
RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, %Appname%, %A_AhkPath%
Menu, Tray, Check, Start on Boot
}
Return
Restart:
Reload
Return
About:
MsgBox ,,%Appname%,Cycle Mouse Monitors`nversion %Version%`n`nCycle mouse across multiple displays.`n`n`n`nBy Melo`[email protected]`n© Melo. All rights reserved.
return
Exit:
ExitApp
Return
WatchMouse:
{
MouseGetPos, x, y ; relative to primary monitor
if (left <= x && x <= (left + PixOffset) )
MouseMove, right-(1+PixOffset), y, ,
if ( (right - PixOffset) <= x && x <= right)
MouseMove, left+(1+PixOffset), y, ,
}