forked from neon-dev/RDPHotkeyHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRDPHotkeyHelper.ahk
68 lines (62 loc) · 2.19 KB
/
RDPHotkeyHelper.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
;@Ahk2Exe-SetMainIcon rhh.ico
;@Ahk2Exe-Set FileVersion, 1.1.0.0
;@Ahk2Exe-Set ProductVersion, 1.1.0.0
#SingleInstance Force
#NoEnv
#KeyHistory 0
UpdateTrayIcon()
Menu, Tray, Tip, RDP Hotkey Helper
Menu, Tray, NoStandard
Menu, Tray, Add, Exit
global RdpWindowTitle := % " - 远程桌面连接" ;
SetTitleMatchMode, 2
DetectHiddenWindows, On
While true {
WinWaitActive, %RdpWindowTitle%
Suspend, On ; rebind all hotkeys, otherwise they won't work in RDP fullscreen mode
Suspend, Off
Sleep, 250
SetNumLockState, On ; the remote desktop client disables num lock upon first connection for some reason
WinWaitNotActive, %RdpWindowTitle%
}
#UseHook
Volume_Mute::PassToLocalMachine()
Volume_Down::PassToLocalMachine()
Volume_Up::PassToLocalMachine()
Media_Next::PassToLocalMachine()
Media_Prev::PassToLocalMachine()
Media_Stop::PassToLocalMachine()
Media_Play_Pause::PassToLocalMachine()
PassToLocalMachine() {
WinGetText, ActiveWindowTitle, A
If Not InStr(ActiveWindowTitle, RdpWindowTitle) {
Send {%A_ThisHotKey%}
Return
}
WM_APPCOMMAND := 0x0319
If (A_ThisHotKey = "Volume_Mute")
PostMessage, WM_APPCOMMAND, 0, 8<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_VOLUME_MUTE
Else If (A_ThisHotKey = "Volume_Down")
PostMessage, WM_APPCOMMAND, 0, 9<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_VOLUME_DOWN
Else If (A_ThisHotKey = "Volume_Up")
PostMessage, WM_APPCOMMAND, 0, 10<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_VOLUME_UP
Else If (A_ThisHotKey = "Media_Next")
PostMessage, WM_APPCOMMAND, 0, 11<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_MEDIA_NEXTTRACK
Else If (A_ThisHotKey = "Media_Prev")
PostMessage, WM_APPCOMMAND, 0, 12<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_MEDIA_PREVIOUSTRACK
Else If (A_ThisHotKey = "Media_Stop")
PostMessage, WM_APPCOMMAND, 0, 13<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_MEDIA_STOP
Else If (A_ThisHotKey = "Media_Play_Pause")
PostMessage, WM_APPCOMMAND, 0, 14<<16,, ahk_class Shell_TrayWnd ; APPCOMMAND_MEDIA_PLAY_PAUSE
}
UpdateTrayIcon() {
If Not (A_IsCompiled) {
try {
Menu, Tray, Icon, rhh.ico
}
} Else {
Menu, Tray, Icon, *
}
}
Exit:
ExitApp