Skip to content

Commit e1ab059

Browse files
committed
Tray next and previous monitor entries
1 parent 485f5f7 commit e1ab059

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

switchmonitor.au3

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
11
#include <WinAPI.au3>
22

3-
HotKeySet("#{PGUP}", "NextMon")
4-
HotKeySet("#{PGDN}", "PrevMon")
3+
Opt("TrayAutoPause", 0)
4+
Opt("TrayMenuMode", 3)
5+
Opt("TrayOnEventMode", 1)
56

6-
While 1
7-
Sleep(60000)
8-
WEnd
7+
Main()
8+
9+
Func Main()
10+
HotKeySet("#{PGUP}", "NextMon")
11+
HotKeySet("#{PGDN}", "PrevMon")
12+
13+
TrayCreateEventItem("Next Monitor", "NextMon")
14+
TrayCreateEventItem("Previous Monitor", "PrevMon")
15+
TrayCreateItem("")
16+
TrayCreateEventItem("Exit", "ExitScript")
17+
18+
Idle()
19+
EndFunc
20+
21+
Func Idle()
22+
While 1
23+
Sleep(60000)
24+
WEnd
25+
EndFunc
26+
27+
Func ExitScript()
28+
Exit
29+
EndFunc
30+
31+
Func TrayCreateEventItem($text, $function)
32+
TrayCreateItem($text)
33+
TrayItemSetOnEvent(-1, $function)
34+
EndFunc
935

1036
Func VirtScreenWidth()
11-
Return _WinAPI_GetSystemMetrics(78)
37+
Return _WinAPI_GetSystemMetrics(78)
1238
EndFunc
1339

1440
Func VirtScreenMinX()
15-
Return _WinAPI_GetSystemMetrics(76)
41+
Return _WinAPI_GetSystemMetrics(76)
1642
EndFunc
1743

1844
Func VirtScreenMaxX()
19-
Return VirtScreenMinX() + VirtScreenWidth()
45+
Return VirtScreenMinX() + VirtScreenWidth()
2046
EndFunc
2147

2248
Func NextMon()
23-
$newX = MouseGetPos(0) + @DesktopWidth
24-
If ($newX <= VirtScreenMaxX()) Then
25-
MouseMove($newX, MouseGetPos(1),0)
26-
EndIf
49+
$newX = MouseGetPos(0) + @DesktopWidth
50+
If ($newX <= VirtScreenMaxX()) Then
51+
MouseMove($newX, MouseGetPos(1),0)
52+
EndIf
2753
EndFunc
2854

2955
Func PrevMon()
30-
$newX = MouseGetPos(0) - @DesktopWidth
31-
if ($newX >= VirtScreenMinX()) Then
32-
MouseMove($newX, MouseGetPos(1),0)
33-
EndIf
56+
$newX = MouseGetPos(0) - @DesktopWidth
57+
if ($newX >= VirtScreenMinX()) Then
58+
MouseMove($newX, MouseGetPos(1),0)
59+
EndIf
3460
EndFunc

0 commit comments

Comments
 (0)