Advertisement
Guest User

vik's OSD

a guest
Sep 1st, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. #SingleInstance Force ; Force only one instance of script
  6. #Persistent ; Ensure the script is permanently running
  7.  
  8. ; CONFIGURATION ==================================================
  9.  
  10. ; the choices available in the menu, separated with '|'
  11. listdata := "Quit Game|HyperSpin|Steam|Kodi|Sleep|Shutdown"
  12.  
  13. ; total elements in menu
  14. elements = 6
  15.  
  16. ; period for checking hyperspin running, in ms
  17. joyrate_check = 2000
  18.  
  19. ; CUSTOM SCRIPTS =================================================
  20. ; These functions are executed when a menu item is chosen
  21. ; Function is automagically called from the menu item name
  22. ; Exemple: if the menu name is "Quit Game",
  23. ; the function FQuit_Game() will be called
  24. ; function is prefixed with 'F', spaces are replaced with '_'
  25.  
  26. FQuit_Game() {
  27.   ; We check for a special close event required
  28.   if WinExist("ahk_class PhyreFrameworkClass") {
  29.     Process Close, HotlineGL.exe
  30.   } else if WinExist("ahk_class YYGameMakerYY") {
  31.     Process Close, Savant_Ascent.exe
  32.  
  33.   ; Else we simply send the Escape key
  34.   } else {
  35.     Send {Escape}
  36.   }
  37. }
  38.  
  39. FHyperSpin() {
  40.   Process Close, Kodi.exe
  41.   Run, "steam://ExitSteam"
  42.   if WinExist("ahk_class ThunderRT6FormDC") ; dafuq HyperSpin
  43.     WinActivate
  44.   else
  45.     Run, "D:\HeavyBox\HyperSpin.exe"
  46. }
  47.  
  48. FSteam() {
  49.   Process Close, HyperSpin.exe
  50.   Process Close, Kodi.exe
  51.   FQuit_Game()
  52.   Process Exist, Steam.exe
  53.   if ErrorLevel
  54.     Run, "steam://open/bigpicture"
  55.   else
  56.     Run, "C:\Program Files (x86)\Steam\Steam.exe" -bigpicture
  57. }
  58.  
  59. FKodi() {
  60.   Process Close, HyperSpin.exe
  61.   Run, "steam://ExitSteam"
  62.   FQuit_Game()
  63.   if WinExist("ahk_class Kodi")
  64.     WinRestore
  65.   else
  66.     Run, "D:\Kodi\Kodi.exe"
  67. }
  68.  
  69. FSleep() {
  70.   ; Sleep/Suspend:
  71.   DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
  72.   ; Hibernate:
  73.   ; DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
  74. }
  75.  
  76. FShutdown() {
  77.   Shutdown, 1
  78. }
  79.  
  80. ; ================================================================
  81.  
  82. index = 1
  83. active := false
  84. prevj2kstatus := false
  85.  
  86. ; Run Joy2Key timer check (that executes label 'CustomJoy2Key' regularly)
  87. setTimer, CustomJoy2Key, %joyrate_check%
  88.  
  89. ; Gui menu settings
  90. Gui +LastFound +AlwaysOnTop +ToolWindow -Caption
  91. Gui, color, 000000
  92. Gui, font, s18 bold, Arial
  93. Gui, Add, Listbox, h192 vActionmenu Choose%index%, %listdata%
  94.  
  95. ; Shows or hide menu
  96. Toggle_GUI() {
  97.   global active
  98.  
  99.   if (active=true) {
  100.     active := false
  101.     Gui, Cancel
  102.  
  103.   } else {
  104.     active := true
  105.     Gui, Show ;, NoActivate ; this avoid activating ahk window
  106.   }
  107. }
  108.  
  109. ; Navigation in menu when menu active
  110. ChoiceMove(dir) {
  111.   global index, elements
  112.   elemv = elements - 1
  113.   if (index > 0 and index < elements and dir = "down")
  114.     index++
  115.   else if (index > 1 and index < elemv and dir = "up")
  116.     index--
  117.   GuiControl, Choose, Actionmenu, %index%
  118. }
  119.  
  120. ; Action on menu selection
  121. ChoiceValidate() {
  122.   global Actionmenu, active
  123.   Gui, Submit
  124.   active := false
  125.   StringReplace, Actionmenu, Actionmenu, %A_SPACE%, _, All
  126.   ; Run the function named F[menu_entry]
  127.   F%Actionmenu%()
  128. }
  129.  
  130. ; xb360 RHat shows/hide menu
  131. 1joy10::Toggle_GUI()
  132.  
  133. ; navigation hotkeys only when menu active
  134. #IfWinActive ahk_class AutoHotkeyGUI
  135. 1joy1::ChoiceValidate()
  136. 1joy3::ChoiceMove("down")
  137. 1joy4::ChoiceMove("up")
  138. return
  139.  
  140. ; The 'function' that checks regularly if HyperSpin is active
  141. ; If yes it runs Joy2Key, else it kills it
  142. CustomJoy2Key:
  143.  if WinActive("ahk_class ThunderRT6FormDC") {
  144.     if (prevj2kstatus=false) {
  145.       Run, D:\HeavyBox\Joy2key\JoyToKey.exe
  146.       prevj2kstatus := true
  147.     }
  148.   } else {
  149.     if (prevj2kstatus=true) {
  150.       Process Close, JoyToKey.exe
  151.       prevj2kstatus := false
  152.     }
  153.   }
  154.   return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement