JacobMIX

Moonlight AutoHotKey script

Jan 15th, 2019
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ;#Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  5.  
  6. ;You can change these however you like or add new ones if you like. All the info you need to do so is here:
  7. ;https://autohotkey.com/docs/KeyList.htm | https://autohotkey.com/docs/misc/Remap.htm | https://www.autohotkey.com/docs/Hotkeys.htm
  8.  
  9. ;Check the config, and info section before you start the script.
  10. ;Make sure your numpad is enabled on the client. Also while this is active normal numpad buttons may not work on the host.
  11.  
  12. ; --------------------------------------------------
  13. ;configs for the script
  14.  
  15. ;Location of the bat file that starts the KillNvStreamer task. (Needed for Numpad9)
  16. KillNvStreamerFullPath=C:\Users\JacobMIX\Desktop\Stuff\Kill nvstramer\Run task - Kill nvstreamer.exe.bat
  17. ;KillNvStreamerFullPath=<Full_Path_To_KillNvStreamer_Bat_Task_Shortcut_Here>
  18. ;You can get the NvStreamer Killer bats from here: https://mega.nz/#F!fQ8kSAzL!b_QgzOeVxFFmhBleEZ4REg | Kill nvstramer.rar
  19.  
  20. ;Your monitor resolutions. (Needed for Numpad6)
  21. leftMonitorWidth = 1920
  22. leftMonitorHeight = 1080
  23. rightMonitorWidth = 1920
  24. rightMonitorHeight = 1080
  25.  
  26. ; --------------------------------------------------
  27. ;Info, and credits.
  28.  
  29. ;For Numpad1
  30. ;Does "Left Windows key"
  31.  
  32. ;For Numpad2
  33. ;Does "Left Alt" Nothing special. Be free to suggest something better on the Moonlight Discord.
  34.  
  35. ;For Numpad3
  36. ;Set's current window to always on top. (Toggable)
  37.  
  38. ;For Numpad4
  39. ;Does "Left Ctrl" Nothing special. Be free to suggest something better on the Moonlight Discord.
  40.  
  41. ;For Numpad5
  42. ;Opens the Alt+Tab menu. Missing features, and is pretty buggy at times. A work in progress.
  43.  
  44. ;For Numpad6
  45. ;Moves the active window from one monitor to the other. Similar to JumpWin.exe, but that stopped working for me for some reason.
  46. ;Based on Thalon's code at http://www.autohotkey.com/forum/topic19440.html [Jon Aquino 2008-09-17]
  47.  
  48. ;For Numpad7
  49. ;Does "Ctrl+Shift+Esc" (Task Manager)
  50.  
  51. ;For Numpad8
  52. ;Does "Prt Sc" (Take screenshot)
  53.  
  54. ;For Numpad9
  55. ;Runs the bat file that runs the task that kills the stream.
  56. ;Check the config section before running this.
  57. ;To Disconect Moonlight normally from the client just "Shifr+Ctrl+Alt+Q" Tho the Numpad9 should also force the stream to close.
  58.  
  59. ;Numpad0+Numpad1
  60. ;Ends this script.<
  61.  
  62.  
  63. ;The actual key shortcuts are below.
  64.  
  65.  
  66. ; --------------------------------------------------
  67.  
  68. Numpad1::LWin ; Left Windows key
  69.  
  70. ; --------------------------------------------------
  71.  
  72. ;Numpad2::LAlt ; Left Alt
  73.  
  74. ; --------------------------------------------------
  75.  
  76. Numpad3::Winset, Alwaysontop, , A ; Set window to always on top. (Toggle)
  77.  
  78. ; --------------------------------------------------
  79.  
  80. Numpad4::LControl ; Left Ctrl
  81.  
  82. ; --------------------------------------------------
  83.  
  84. Numpad5::alttabandmenu
  85. #if winactive("ahk_class TaskSwitcherWnd")
  86. !Numpad5 up::send {Alt Up}
  87.  
  88. !LButton:: ; Left mouse button. The ! prefix makes it fire while the Alt key is down (which it is if the alt-tab menu is visible).
  89. if WinExist("ahk_class #32771") ; Indicates that the alt-tab menu is present on the screen.
  90. sleep, 2000
  91. Send {Click}{Alt Up}{Numpad5 Up}
  92. sleep, 2000
  93. return
  94.  
  95. Numpad5 & Numpad2::
  96. if WinExist("ahk_class #32771")
  97. Send {Blind}{Down}
  98. return
  99. Numpad5 & Numpad4::
  100. if WinExist("ahk_class #32771")
  101. Send {Blind}{Left}
  102. return
  103. Numpad5 & Numpad6::
  104. if WinExist("ahk_class #32771")
  105. Send {Blind}{Right}
  106. return
  107. Numpad5 & Numpad8::
  108. if WinExist("ahk_class #32771")
  109. Send {Blind}{Up}
  110. return
  111.  
  112. ; --------------------------------------------------
  113.  
  114. Numpad6:: ; Numpad6
  115. activeWindow := WinActive("A")
  116. if activeWindow = 0
  117. {
  118. return
  119. }
  120. WinGet, minMax, MinMax, ahk_id %activeWindow%
  121. if minMax = 1
  122. {
  123. WinRestore, ahk_id %activeWindow%
  124. }
  125. WinGetPos, x, y, width, height, ahk_id %activeWindow%
  126. if x < 0
  127. {
  128. xScale := rightMonitorWidth / leftMonitorWidth
  129. yScale := rightMonitorHeight / leftMonitorHeight
  130. x := leftMonitorWidth + x
  131. newX := x * xScale
  132. newY := y * yScale
  133. newWidth := width * xScale
  134. newHeight := height * yScale
  135. }
  136. else
  137. {
  138. xScale := leftMonitorWidth / rightMonitorWidth
  139. yScale := leftMonitorHeight / rightMonitorHeight
  140. newX := x * xScale
  141. newY := y * yScale
  142. newWidth := width * xScale
  143. newHeight := height * yScale
  144. newX := newX - leftMonitorWidth
  145. }
  146. WinMove, ahk_id %activeWindow%, , %newX%, %newY%, %newWidth%, %newHeight%
  147. if minMax = 1
  148. {
  149. WinMaximize, ahk_id %activeWindow%
  150. }
  151. WinActivate ahk_id %activeWindow% ;Needed - otherwise another window may overlap it
  152. return
  153.  
  154. ; --------------------------------------------------
  155.  
  156. Numpad7::<^<+Esc ; Ctrl Shift Esc (Task Manager)
  157.  
  158. ; --------------------------------------------------
  159.  
  160. Numpad8::PrintScreen ;Prt Sc (Take screenshot)
  161.  
  162. ; --------------------------------------------------
  163.  
  164. Numpad9::Run, "%KillNvStreamerFullPath%" ; Runs the bat file that runs the task that kills the stream.
  165.  
  166. ; --------------------------------------------------
  167.  
  168. Numpad0 & Numpad1::ExitApp ; Numpad0+Numpad1 will close this script. (Need to be on the last line)
Advertisement
Add Comment
Please, Sign In to add comment