├── LICENSE ├── RDPHotkeyHelper.ahk ├── README.md └── rhh.ico /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Neon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RDPHotkeyHelper.ahk: -------------------------------------------------------------------------------- 1 | ;@Ahk2Exe-SetMainIcon rhh.ico 2 | ;@Ahk2Exe-Set FileVersion, 1.3.0.0 3 | ;@Ahk2Exe-Set ProductVersion, 1.3.0.0 4 | ;@Ahk2Exe-PostExec "MPRESS.exe" "%A_WorkFileName%" -q -x, 0,, 1, 1 5 | 6 | #SingleInstance Force 7 | KeyHistory(0) 8 | If (!A_IsCompiled && FileExist("rhh.ico")) { 9 | TraySetIcon("rhh.ico") 10 | } 11 | A_IconTip := "RDP Hotkey Helper" 12 | Tray:= A_TrayMenu 13 | Tray.Delete() 14 | Tray.Add("Exit", Exit) 15 | ExeNamesPattern := "i)\\(mstsc|msrdc|ApplicationFrameHost|VMConnect)\.exe$" 16 | SetTitleMatchMode("RegEx") 17 | While true { 18 | global RdpHwnd := 0 19 | WinWaitActive("ahk_exe " ExeNamesPattern) 20 | RdpHwnd := WinExist("A") 21 | Suspend(true) ; rebind all hotkeys, otherwise they won't work in RDP fullscreen mode 22 | Suspend(false) 23 | Sleep(250) 24 | WinWaitNotActive("ahk_id " RdpHwnd) 25 | } 26 | 27 | #UseHook 28 | Volume_Mute::PassToLocalMachine() 29 | Volume_Down::PassToLocalMachine() 30 | Volume_Up::PassToLocalMachine() 31 | Media_Next::PassToLocalMachine() 32 | Media_Prev::PassToLocalMachine() 33 | Media_Stop::PassToLocalMachine() 34 | Media_Play_Pause::PassToLocalMachine() 35 | 36 | PassToLocalMachine() { 37 | If (RdpHwnd == 0 || WinExist("A") != RdpHwnd) { 38 | Send("{" A_ThisHotKey "}") 39 | Return 40 | } 41 | WM_APPCOMMAND := 0x0319 42 | If (A_ThisHotKey = "Volume_Mute") 43 | PostMessage(WM_APPCOMMAND, 0, 8<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_VOLUME_MUTE 44 | Else If (A_ThisHotKey = "Volume_Down") 45 | PostMessage(WM_APPCOMMAND, 0, 9<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_VOLUME_DOWN 46 | Else If (A_ThisHotKey = "Volume_Up") 47 | PostMessage(WM_APPCOMMAND, 0, 10<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_VOLUME_UP 48 | Else If (A_ThisHotKey = "Media_Next") 49 | PostMessage(WM_APPCOMMAND, 0, 11<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_MEDIA_NEXTTRACK 50 | Else If (A_ThisHotKey = "Media_Prev") 51 | PostMessage(WM_APPCOMMAND, 0, 12<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_MEDIA_PREVIOUSTRACK 52 | Else If (A_ThisHotKey = "Media_Stop") 53 | PostMessage(WM_APPCOMMAND, 0, 13<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_MEDIA_STOP 54 | Else If (A_ThisHotKey = "Media_Play_Pause") 55 | PostMessage(WM_APPCOMMAND, 0, 14<<16, , "ahk_class Shell_TrayWnd") ; APPCOMMAND_MEDIA_PLAY_PAUSE 56 | } 57 | 58 | Exit(*) { 59 | ExitApp() 60 | } 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RDPHotkeyHelper 2 | RDPHotkeyHelper is an AutoHotkey v2 script which redirects media keys to the local machine while working within a remote desktop session. 3 | 4 | Supported clients: 5 | - Microsoft's standard remote desktop connection 6 | - Microsoft Remote Desktop from the Microsoft Store 7 | - Hyper-V Virtual Machine Connection (https://github.com/neon-dev/RDPHotkeyHelper/issues/7) 8 | - Azure Remote Desktop Client (https://github.com/neon-dev/RDPHotkeyHelper/pull/11) 9 | 10 | Using media keys on the remote host is still possible by holding down `Ctrl`, `Shift` or `Alt` when pressing the media key. 11 | If you want to use different hotkeys as media keys, please refer to https://github.com/neon-dev/RDPHotkeyHelper/issues/10#issuecomment-2255789905. 12 | -------------------------------------------------------------------------------- /rhh.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neon-dev/RDPHotkeyHelper/81c54faf0131d3bb4a59b0eba2fde8fa5f3efd88/rhh.ico --------------------------------------------------------------------------------