Advertisement
Guest User

XBMC Launcher Additions

a guest
Jan 5th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * * * Compile_AHK SETTINGS BEGIN * * *
  3.  
  4. [AHK2EXE]
  5. Exe_File=%In_Dir%\XBMCLauncher.exe
  6. Created_Date=1
  7. [VERSION]
  8. Set_Version_Info=1
  9. Company_Name=baijuxavior@gmail.com
  10. File_Description=Customize XBMC Startup
  11. File_Version=3.1.0.0
  12. Inc_File_Version=0
  13. Internal_Name=XBMCLauncher
  14. Legal_Copyright=C@P Baiju Xavior
  15. Original_Filename=XBMCLauncher
  16. Product_Name=XBMCLauncher
  17. Product_Version=3.1.0.0
  18. [ICONS]
  19. Icon_1=%In_Dir%\XBMCLauncher.ico
  20. Icon_2=%In_Dir%\XBMCLauncher.ico
  21.  
  22. * * * Compile_AHK SETTINGS END * * *
  23. */
  24.  
  25. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  26. #Warn  ; Recommended for catching common errors.
  27. #SingleInstance ignore ; create only one running instance
  28. #Include tf.ahk ; include file manipulation
  29. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  30. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  31.  
  32. DllCall("CreateMutex", "uint", 0, "int", false, "str", "xbmc_launcher_mutex") ; create a mutex to find whether the application is already running while installation.
  33.  
  34. ProgFiles32() ;get 32 bit program files folder
  35. {
  36.     EnvGet, ProgFiles32, ProgramFiles(x86)
  37.     if ProgFiles32 = ; Probably not on a 64-bit system.
  38.     EnvGet, ProgFiles32, ProgramFiles
  39.     Return %ProgFiles32%
  40. }
  41.  
  42. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           GLOBAL VARIABLES DECLARATION AND DEFAULT VALUES     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  43.  
  44.  
  45. Global ProgFiles := ProgFiles32() ;Program files path
  46. global SettingsPath := A_AppData . "\XBMCLauncher\Settings.ini"
  47. global XBMCPath := ProgFiles . "\xbmc\xbmc.exe"
  48. global XBMConiMONPath := ProgFiles . "\xbmc-on-imon-v0.1.9.5\xbmconimon.exe"
  49. global iMONPath := ProgFiles . "\SoundGraph\iMON\iMON.exe"
  50. global version = 3.1
  51.  
  52. global FocusDelay := GetSettings("Delay", 10000)
  53. global FocusOnce := GetSettings("FocusOnce", 0)
  54. global DisableFocusTemporarily = 0
  55. global FocussedOnce = 0
  56. global FocusCount = 0
  57. global WinKeySent = 0
  58. global ForceClose := GetSettings("ForceClose", 0)
  59. global StartExplorer := GetSettings("StartExplorer", 1)
  60. global PressWinKey := GetSettings("PressWinKey", 1)
  61. global ShowShutdownMenu := GetSettings("Shutdown", 0)
  62. global ShutdownAction := GetSettings("Shutdown", "u")
  63. global ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  64. global EditDialogButton := GetSettings("EditDialogButtonMenu", 0)
  65. global ExternalPlayerPath := GetSettings("ExternalPlayer_Path", ProgFiles . "\ArcSoft\TotalMedia Theatre 5\uMCEPlayer5.exe")
  66. global ExternalPlayerRunning = 0
  67. global Suspending = 0
  68. global StartupDelay := GetSettings("StartupDelay", 0)
  69. global StartAtWinLogon := GetSettings("StartAtWinLogon", 1)
  70. global StartAtWinResume := GetSettings("StartAtWinResume", 1)
  71. global BreakFocus = 0 ; break focus while setting xbmclauncher settings
  72. global ShellName
  73.  
  74. XBMCPath := GetSettings("XBMC_Path", XBMCPath)
  75. XBMConiMONPath := GetSettings("XBMConiMON_Path", XBMConiMONPath)
  76. iMONPath := GetSettings("iMON_Path", iMONPath)
  77.  
  78. Global App1 := GetSettings("App1_Path", " ")
  79. Global App2 := GetSettings("App2_Path", " ")
  80. Global App3 := GetSettings("App3_Path", " ")
  81. global StartApps := GetSettings("StartApps", 0)
  82. global PreventFocusApps := GetSettings("PreventFocusApps", 0)
  83.  
  84. Global App4 := GetSettings("App4_Path", " ")
  85. Global App5 := GetSettings("App5_Path", " ")
  86. Global App6 := GetSettings("App6_Path", " ")
  87. global StartApps_1 := GetSettings("StartApps_1", 0)
  88. global PreventFocusApps_1 := GetSettings("PreventFocusApps_1", 0)
  89. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    CREATE MENU ITEMS      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  90.  
  91.     RegRead, ShellName, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell
  92.     SplitPath, ShellName, ShellName
  93.        
  94.     If ShellName != XBMCLauncher.exe
  95.         ShellName = Explorer.exe
  96.    
  97.  
  98.  
  99. fdelay := FocusDelay // 1000 ; variable to show menu name with delay
  100. sdelay := StartupDelay // 1000
  101. IfExist, %A_WorkingDir%\XBMCLauncher.ico
  102. Menu, Tray, Icon, %A_WorkingDir%\XBMCLauncher.ico ; create tray icon.
  103. Menu, Tray, add, Start XBMC [Win+Alt+Enter], MenuStartXBMCHandler
  104. Menu, Tray, add, Start XBMC When Windows Starts, MenuStartXBMCAtWindowsLogonHandler
  105. Menu, Tray, add, Start XBMC When Windows Resumes from Sleep, MenuStartXBMCAtWindowsResumeHandler
  106. Menu, Tray, UnCheck, Start XBMC When Windows Starts
  107. Menu, Tray, UnCheck, Start XBMC When Windows Resumes from Sleep
  108. Menu, Tray, add, Change Startup Delay [%sdelay% sec], MenuSetStartupDelayHandler
  109. Menu, Tray, add ;add separator
  110. Menu, Tray, add, Change Focus Delay [%fdelay% sec], MenuSetFocusDelayHandler
  111. Menu, Tray, add, Disable Focus Temporarily [Win+F9], MenuDisableFocusHandler
  112. Menu, Tray, UnCheck, Disable Focus Temporarily [Win+F9]
  113. Menu, Tray, add, Check Focus Only Once, MenuCheckFocusOnceHandler
  114. Menu, Tray, UnCheck, Check Focus Only Once
  115. Menu, Tray, add ;add separator
  116. if (ShowShutdownMenu <> 0)
  117.     Menu, Tray, add, Set Shutdown Action (for confluence skin only), MenuSetShutdownActionHandler
  118. Menu, Tray, add, Force Close XBMC on Suspend, MenuForceCloseXBMCHandler
  119. Menu, Tray, UnCheck, Force Close XBMC on Suspend
  120. Menu, Tray, add, Start Windows Explorer when XBMC is closed, MenuStartExplorerHandler
  121. Menu, Tray, UnCheck, Start Windows Explorer when XBMC is closed
  122. Menu, Tray, add, Send Windows Key when XBMC is closed, MenuPressWinKeyHandler
  123. Menu, Tray, UnCheck, Send Windows Key when XBMC is closed
  124.  
  125. Menu, Tray, add ;add separator
  126. shell := RTrim(ShellName, "`.exe")
  127. Menu, Tray, add, Change Windows Shell [Current Shell - %shell%], MenuChangeShellHandler
  128. Menu, Tray, add ;add separator
  129. Menu, Tray, add, Set XBMC Path, MenuSetXBMCPathHandler
  130. Menu, Tray, add, Set XBMConiMON Path, MenuSetXBMConiMONPathHandler
  131. Menu, Tray, add, Set iMON Path, MenuSetiMONPathHandler
  132. Menu, Tray, add, Set External Player Path (for focus disable), MenuSetExternalPlayerHandler
  133. Menu, Tray, add ;add separator
  134.  
  135.  
  136. SplitPath, App1, AppName
  137. if (AppName = "")
  138.     AppName = Not Set
  139. Menu, Tray, add, Set Application 1 - %AppName%, MenuSetApp1Handler
  140. SplitPath, App2, AppName
  141. if (AppName = "")
  142.     AppName = Not Set
  143. Menu, Tray, add, Set Application 2 - %AppName%, MenuSetApp2Handler
  144. SplitPath, App3, AppName
  145. if (AppName = "")
  146.     AppName = Not Set
  147. Menu, Tray, add, Set Application 3 - %AppName%, MenuSetApp3Handler
  148.  
  149. Menu, Tray, add, Start First Group Applications with XBMC Launcher, MenuStartAppsHandler
  150. Menu, Tray, UnCheck, Start First Group Applications with XBMC Launcher
  151. Menu, Tray, add, First Group Apps Prevent Focus, MenuAppsPreventFocusHandler
  152. Menu, Tray, UnCheck, First Group Apps Prevent Focus
  153.  
  154. Menu, Tray, add ;add separator
  155.  
  156.  
  157. SplitPath, App4, AppName
  158. if (AppName = "")
  159.     AppName = Not Set
  160. Menu, Tray, add, Set Application 4 - %AppName%, MenuSetApp4Handler
  161. SplitPath, App5, AppName
  162. if (AppName = "")
  163.     AppName = Not Set
  164. Menu, Tray, add, Set Application 5 - %AppName%, MenuSetApp5Handler
  165. SplitPath, App6, AppName
  166. if (AppName = "")
  167.     AppName = Not Set
  168. Menu, Tray, add, Set Application 6 - %AppName%, MenuSetApp6Handler
  169.  
  170. Menu, Tray, add, Start Second Group Applications with XBMC Launcher, MenuStartAppsHandler
  171. Menu, Tray, UnCheck, Start Second Group Applications with XBMC Launcher
  172. Menu, Tray, add, Second Group Apps Prevent Focus, MenuAppsPreventFocusHandler
  173. Menu, Tray, UnCheck, Second Group Apps Prevent Focus
  174.  
  175.  
  176.  
  177. Menu, Tray, add  ;add separator
  178. Menu, Tray, add, Open XBMC Programs Folder, MenuOpenXBMCFolderHandler
  179. Menu, Tray, add, Open XBMC Application Data Folder, MenuOpenXBMCAppFolderHandler
  180. Menu, Tray, add, Open XBMCLauncher Settings Folder, MenuOpenXBMCLauncherSettingsHandler
  181. Menu, Tray, add
  182. Menu, Tray, add, Turn off Display [Win+F11], MenuTurnOffDisplay
  183. Menu, Tray, add, About XBMCLauncher, MenuAboutHandler
  184. Menu, Tray, add
  185. Menu, tray, NoStandard
  186. Menu, tray, Standard
  187.  
  188. if (FocusOnce = 1)
  189.     Menu, Tray, Check, Check Focus Only Once
  190.    
  191. if (ForceClose = 1)
  192.     Menu, Tray, Check, Force Close XBMC on Suspend
  193.  
  194. if (StartExplorer = 1)
  195.     Menu, Tray, Check, Start Windows Explorer when XBMC is closed
  196.    
  197. if (PressWinKey = 1)
  198.     Menu, Tray, Check, Send Windows Key when XBMC is closed
  199.  
  200. if (StartAtWinLogon = 1)
  201.     Menu, Tray, Check, Start XBMC When Windows Starts
  202.  
  203. if (StartAtWinResume = 1)
  204.     Menu, Tray, Check, Start XBMC When Windows Resumes from Sleep
  205.  
  206. if (StartApps = 1)
  207.     Menu, Tray, Check, Start First Group Applications with XBMC Launcher
  208.    
  209. if (StartApps_1 = 1)
  210.     Menu, Tray, Check, Start Second Group Applications with XBMC Launcher
  211.  
  212. if (PreventFocusApps = 1)
  213.     Menu, Tray, Check, First Group Apps Prevent Focus
  214.    
  215. if (PreventFocusApps_1 = 1)
  216.     Menu, Tray, Check, Second Group Apps Prevent Focus
  217.  
  218.  
  219. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       PROMPT FOR XBMC IF NOT FOUND        <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  220.  
  221.  
  222.  
  223. IfNotExist, %XBMCPath% ; if xbmc.exe not exists, prompt to select xbmc.exe manually
  224.     {
  225.         MsgBox, 36, Select XBMC.exe, Could not locate XBMC executable file. Do you want to select the file manually?, 10
  226.         ifMsgBox Yes
  227.         {
  228.             XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
  229.             if (ShowShutdownMenu <> 0)
  230.             {   SplitPath, XBMCPath, ,newpath
  231.                 FileCopy, %A_WorkingDir%\ShutdownAction.exe, %newpath%, 1
  232.                 FileCopy, %A_WorkingDir%\ShutdownAction.py, %newpath%, 1
  233.                 FileCopy, %A_WorkingDir%\CloseXBMC.exe, %newpath%, 1
  234.                 FileCopy, %A_WorkingDir%\CloseXBMC.py, %newpath%, 1
  235.                 FileCopy, %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p\DialogButtonMenu_Backup.xml, 0
  236.                 FileCopy, %A_WorkingDir%\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p, 1
  237.                
  238.                 newdialogfile = %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml
  239.                 oldline2 = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
  240.                 newline2 = <onclick>XBMC.RunScript(%newpath%\ShutdownAction.py)</onclick>
  241.                 TF_Replace("!" . newdialogfile, oldline2, newline2)
  242.                 oldline2 = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
  243.                 newline2 = <onclick>XBMC.RunScript(%newpath%\CloseXBMC.py)</onclick>
  244.                 TF_Replace("!" . newdialogfile, oldline2, newline2)
  245.                 IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
  246.                 IniWrite, 1, %SettingsPath%, Settings, UninstallDeleteFile
  247.             }
  248.         }      
  249.     }
  250.  
  251.  
  252.  
  253. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           LAUNCH APPLICATIONS         <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  254.  
  255. If (StartAtWinLogon = 1)
  256. {
  257.    
  258. Sleep %StartupDelay%
  259. LaunchApplication(XBMCPath)
  260. ;WinWait,XBMC,,6 ; wait 6 seconds
  261. WinActivate, ahk_class XBMC ; activate and bring to front.
  262. }
  263.  
  264. LaunchApplication(iMONPath)
  265. LaunchApplication(XBMConiMONPath)
  266.  
  267. If (StartApps = 1)
  268. {
  269. LaunchApplication(App1)
  270. LaunchApplication(App2)
  271. LaunchApplication(App3)
  272. }
  273.  
  274. If (StartApps_1 = 1)
  275. {
  276. LaunchApplication(App4)
  277. LaunchApplication(App5)
  278. LaunchApplication(App6)
  279. }
  280.  
  281. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       MODIFY SHUTDOWN DIALOG BUTTON MENU - FOR CUSTOM MENU ONLY       <<<<<<<<<<<<<<<<
  282.  
  283.  
  284. If (EditDialogButton = 1)
  285.     {
  286.        
  287.         SplitPath, XBMCPath, , xbmcdir
  288.         dialogfile = %xbmcdir%\addons\skin.confluence\720p\DialogButtonMenu.xml
  289.         IfExist, %dialogfile%
  290.         {  
  291.             oldline = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
  292.             newline = <onclick>XBMC.RunScript(%xbmcdir%\ShutdownAction.py)</onclick>
  293.             TF_Replace("!" . dialogfile, oldline, newline)
  294.             oldline = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
  295.             newline = <onclick>XBMC.RunScript(%xbmcdir%\CloseXBMC.py)</onclick>
  296.             TF_Replace("!" . dialogfile, oldline, newline)
  297.             IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
  298.         }
  299.     }      
  300.            
  301.    
  302.  
  303.     ModifyShutdownLabel(ShutdownLabel)
  304.     {
  305.         SplitPath, XBMCPath, , dir
  306.         dialogfile1 = %dir%\addons\skin.confluence\720p\DialogButtonMenu.xml
  307.         IfExist, %dialogfile1%
  308.         {   lbl := GetSettings("ShutdownLabel", "Shutdown")
  309.             if (lbl <> ShutdownLabel)
  310.             {
  311.                 oldline1 = <label>%lbl%</label>
  312.                 newline1 = <label>%ShutdownLabel%</label>
  313.                 TF_Replace("!" . dialogfile1, oldline1, newline1)
  314.             }
  315.         }
  316.     }
  317.    
  318.            
  319.  
  320.  
  321.     ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     START XBMC ON WINDOWS RESUME FROM HIBERNATION OR SLEEP     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  322.  
  323.  
  324. OnMessage(0x218, "WM_POWERBROADCAST")
  325.  
  326. WM_POWERBROADCAST(wParam, lParam)
  327. {
  328.    
  329.     If (wParam=4) ;suspend
  330.     {
  331.         Suspending = 1 ;System is suspending. Do not start Explorer.       
  332.         if (ForceClose = 1) ; force close xbmc
  333.         {
  334.             Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  335.             If (ErrorLevel >= 1) ; If it is running
  336.             {
  337.             Process, Close, %ErrorLevel%  
  338.             Process, WaitClose, %ErrorLevel%
  339.             sleep 1000
  340.             }
  341.         }
  342.     }  
  343.    
  344.     If (wParam=7 and StartAtWinResume = 1) ;on resuming from suspend state
  345.         {
  346.                 LaunchApplication(XBMConiMONPath)
  347.            
  348.                 Sleep %StartupDelay%
  349.                 ;WinWait,XBMC,,6 ; wait 6 seconds
  350.                 WinActivate, ahk_class XBMC ; activate and bring to front.
  351.  
  352.                 LaunchApplication(XBMCPath)
  353.            
  354.                 if (DisableFocusTemporarily = 1)
  355.                 {
  356.                     DisableFocusTemporarily() ;re enable focus
  357.                 }      
  358.            
  359.                 Suspending = 0
  360.                 FocussedOnce = 0
  361.            
  362.                
  363.         }
  364.        
  365. }
  366.  
  367.  
  368.  
  369.  
  370. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TIMER DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  371.  
  372.  
  373. SetTimer, MonitorEvents, 500
  374.  
  375. MonitorEvents:
  376. KeepFocus()
  377. StartExplorer()
  378. PressWinKey()
  379. MonitorCustomShutdown()
  380. DisableFocusOnExternalPlayer()
  381. return
  382.  
  383.  
  384.  
  385.  
  386. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  SYSTEM TRAY MENU HANDLERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  387.  
  388.  
  389. MenuStartXBMCHandler:
  390. {
  391. LaunchApplication(XBMCPath)
  392. Sleep, 2000
  393. WinActivate, ahk_class XBMC
  394. FocussedOnce = 0
  395. }
  396. return
  397.  
  398.  
  399. MenuStartXBMCAtWindowsLogonHandler:
  400. StartXBMCAtWinLogon()
  401. return
  402.  
  403. MenuStartXBMCAtWindowsResumeHandler:
  404. StartXBMCAtWinResume()
  405. return
  406.  
  407. MenuSetStartupDelayHandler:
  408. SetStartupDelay()
  409. return
  410.  
  411.  
  412. MenuSetFocusDelayHandler:
  413. SetFocusDelay()
  414. return
  415.  
  416. MenuDisableFocusHandler:
  417. DisableFocusTemporarily()
  418. return
  419.  
  420. MenuCheckFocusOnceHandler:
  421. CheckFocusOnce()
  422. return
  423.  
  424.  
  425. MenuSetXBMCPathHandler:
  426. XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
  427. return
  428.  
  429. MenuSetXBMConiMONPathHandler:
  430. XBMConiMONPath := SaveApplicationPath("XBMConiMON", XBMConiMONPath)
  431. return
  432.  
  433. MenuSetiMONPathHandler:
  434. iMONPath := SaveApplicationPath("iMON", iMONPath)
  435. return
  436.  
  437. MenuSetExternalPlayerHandler:
  438. ExternalPlayerPath := SaveApplicationPath("ExternalPlayer", ExternalPlayerPath)
  439. return
  440.  
  441.  
  442. MenuSetApp1Handler:
  443. SplitPath, App1, AppName
  444. if (AppName = "")
  445.     AppName = Not Set
  446. oldmenuname = Set Application 1 - %AppName%
  447. App1 := SaveApplicationPath("App1", App1)
  448.  
  449. SplitPath, App1, AppName
  450. if (AppName = "")
  451.     AppName = Not Set
  452. newmenuname = Set Application 1 - %AppName%
  453.  
  454. if (oldmenuname != newmenuname)
  455.         {
  456.             menu, tray, rename, %oldmenuname%, %newmenuname%
  457.         }
  458. return
  459.  
  460. MenuSetApp2Handler:
  461. SplitPath, App2, AppName
  462. if (AppName = "")
  463.     AppName = Not Set
  464. oldmenuname = Set Application 2 - %AppName%
  465. App2 := SaveApplicationPath("App2", App2)
  466.  
  467. SplitPath, App2, AppName
  468. if (AppName = "")
  469.     AppName = Not Set
  470. newmenuname = Set Application 2 - %AppName%
  471.  
  472. if (oldmenuname != newmenuname)
  473.         {
  474.             menu, tray, rename, %oldmenuname%, %newmenuname%
  475.         }
  476. return
  477.  
  478. MenuSetApp3Handler:
  479. SplitPath, App3, AppName
  480. if (AppName = "")
  481.     AppName = Not Set
  482. oldmenuname = Set Application 3 - %AppName%
  483. App3 := SaveApplicationPath("App3", App3)
  484.  
  485. SplitPath, App3, AppName
  486. if (AppName = "")
  487.     AppName = Not Set
  488. newmenuname = Set Application 3 - %AppName%
  489.  
  490. if (oldmenuname != newmenuname)
  491.         {
  492.             menu, tray, rename, %oldmenuname%, %newmenuname%
  493.         }
  494. return
  495.  
  496. MenuSetApp4Handler:
  497. SplitPath, App4, AppName
  498. if (AppName = "")
  499.     AppName = Not Set
  500. oldmenuname = Set Application 4 - %AppName%
  501. App4 := SaveApplicationPath("App4", App4)
  502.  
  503. SplitPath, App4, AppName
  504. if (AppName = "")
  505.     AppName = Not Set
  506. newmenuname = Set Application 4 - %AppName%
  507.  
  508. if (oldmenuname != newmenuname)
  509.         {
  510.             menu, tray, rename, %oldmenuname%, %newmenuname%
  511.         }
  512. return
  513.  
  514. MenuSetApp5Handler:
  515. SplitPath, App5, AppName
  516. if (AppName = "")
  517.     AppName = Not Set
  518. oldmenuname = Set Application 5 - %AppName%
  519. App5 := SaveApplicationPath("App5", App5)
  520.  
  521. SplitPath, App5, AppName
  522. if (AppName = "")
  523.     AppName = Not Set
  524. newmenuname = Set Application 5 - %AppName%
  525.  
  526. if (oldmenuname != newmenuname)
  527.         {
  528.             menu, tray, rename, %oldmenuname%, %newmenuname%
  529.         }
  530. return
  531.  
  532. MenuSetApp6Handler:
  533. SplitPath, App6, AppName
  534. if (AppName = "")
  535.     AppName = Not Set
  536. oldmenuname = Set Application 6 - %AppName%
  537. App6 := SaveApplicationPath("App6", App6)
  538.  
  539. SplitPath, App6, AppName
  540. if (AppName = "")
  541.     AppName = Not Set
  542. newmenuname = Set Application 6 - %AppName%
  543.  
  544. if (oldmenuname != newmenuname)
  545.         {
  546.             menu, tray, rename, %oldmenuname%, %newmenuname%
  547.         }
  548. return
  549.  
  550. MenuStartAppsHandler:
  551. SetStartApps()
  552. return
  553.  
  554. MenuAppsPreventFocusHandler:
  555. SetPreventFocusApps()
  556. return
  557.  
  558. MenuSetShutdownActionHandler:
  559. SetShutdownAction()
  560. return
  561.  
  562. MenuForceCloseXBMCHandler:
  563. ForceCloseXBMC()
  564. return
  565.  
  566. MenuStartExplorerHandler:
  567. SetStartExplorer()
  568. return
  569.  
  570. MenuPressWinKeyHandler:
  571. SetPressWinKey()
  572. return
  573.  
  574. MenuChangeShellHandler:
  575. ChangeShell()
  576. return
  577.  
  578. MenuOpenXBMCAppFolderHandler:
  579. {
  580.     appfolder := A_AppData . "\XBMC"
  581.     ifexist, %appfolder%
  582.         run %appfolder%
  583. }
  584.  
  585. return
  586.  
  587. MenuOpenXBMCFolderHandler:
  588. {
  589.     SplitPath, XBMCPath, , xbmcfolder
  590.     IfExist, %xbmcfolder%
  591.         run %xbmcfolder%
  592. }
  593.  
  594. return
  595.  
  596. MenuOpenXBMCLauncherSettingsHandler:
  597. {
  598.     SplitPath, SettingsPath, , settingsfolder
  599.     IfExist, %settingsfolder%
  600.         run %settingsfolder%
  601. }
  602. return
  603.  
  604. MenuTurnOffDisplay:
  605. {
  606.     Sleep 1000
  607.     SendMessage 0x112, 0xF170, 2,,Program Manager
  608. }
  609. return
  610.  
  611.  
  612. MenuAboutHandler:
  613. {
  614.     BreakFocus = 1
  615. MsgBox XBMCLauncher %version% `n`nAn application to customize your XBMC HTPC. `nDesigned and programmed by baijuxavior@gmail.com`n`nAdditional programming by Snood ;I hope you don't mind this addition
  616. }
  617. BreakFocus = 0
  618. return
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               FUNCTIONS                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  628.  
  629.  
  630.  
  631.  
  632.  
  633. KeepFocus()
  634. {
  635.     if (FocusDelay = 0 or DisableFocusTemporarily = 1 or ExternalPlayerRunning = 1)
  636.         {
  637.         FocusCount = 0
  638.         return
  639.         }
  640.        
  641.     FocusCount := FocusCount + 1
  642.        
  643.        
  644.     If (FocusCount = (FocusDelay * 2) // 1000)
  645.         {
  646.            
  647.             FocusCount = 0
  648.         if (FocusOnce = 0)
  649.             {
  650.             SendFocus()
  651.             return
  652.             }
  653.        
  654.         if (FocusOnce = 1 and FocussedOnce = 0)
  655.             {
  656.             SendFocus()
  657.             FocussedOnce = 1
  658.             }
  659.         }
  660.    
  661. }
  662.  
  663.  
  664. SendFocus()
  665. {
  666.     Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  667.     If (ErrorLevel >= 1 and BreakFocus = 0)
  668.         WinActivate, ahk_class XBMC
  669.            
  670. }
  671.  
  672.  
  673.  
  674. GetSettings(SettingsName, DefaultValue) ;Get settings from Settings.ini file
  675. {
  676.    
  677.     If FileExist(SettingsPath)
  678.         {
  679.         IniRead, result, %SettingsPath%, Settings, %SettingsName%, %DefaultValue%
  680.         return %result%
  681.         }
  682.     else
  683.         return %DefaultValue%
  684. }
  685.  
  686.  
  687. SetFocusDelay() ;function to Change Focus Delay
  688. {
  689.     BreakFocus = 1
  690.     currentdelay := FocusDelay // 1000
  691.     if currentdelay is not number
  692.         currentdelay = 5
  693.    
  694.     InputBox, Delay, XBMCLauncher - Specify Time Delay, Specify the delay between refocussing of XBMC in seconds. `n `nEnter '0' seconds to prevent refocus permanently., , , , , , , , %currentdelay%
  695.  
  696.     If ErrorLevel ; If cancel was pressed
  697.         {
  698.             ;MsgBox cancel
  699.         }
  700.     else
  701.         {
  702.             If Delay is not number
  703.                 {
  704.                 Delay = 5000
  705.                 }
  706.             Else
  707.                 {
  708.                 Delay := Delay * 1000
  709.                 }
  710.        
  711.                 IniWrite, %Delay%, %SettingsPath%, Settings, Delay
  712.                 FocusDelay := Delay
  713.                 fdelaynew := FocusDelay // 1000
  714.                 old_name = Change Focus Delay [%currentdelay% sec]
  715.                 new_name = Change Focus Delay [%fdelaynew% sec]
  716.                                
  717.                 if (old_name != new_name)
  718.                 {
  719.                     menu, tray, rename, %old_name%, %new_name%
  720.                 }
  721.                
  722.                    
  723.         }
  724.        
  725.     BreakFocus = 0 
  726. }
  727.  
  728.  
  729.  
  730. LaunchApplication(AppPath) ; function to start applications
  731. {
  732. SplitPath, AppPath, FileName ;get filename without path
  733. Process, Exist, %FileName% ; check to see if 'FileName' is running
  734. If (ErrorLevel = 0) ;if not running
  735.     {
  736.     if FileExist(AppPath)
  737.         {
  738.         run %AppPath%
  739.         }
  740.     Else
  741.         {
  742.         ;traytip, Message, %AppPath% not found, 5, 1
  743.         }
  744.     }
  745.     Else ; file already running
  746.     {
  747.     ;traytip, Message, %FileName% already running, 5, 1
  748.     }
  749. }
  750.  
  751.  
  752. SaveApplicationPath(AppName, StartPath)
  753. {
  754.     BreakFocus = 1
  755. FileSelectFile, SelectedFileName,1 ,%StartPath%, Select %AppName%.exe, *.exe
  756. if SelectedFileName !=
  757.     {
  758.         BreakFocus = 0
  759.         IniWrite, %SelectedFileName%, %SettingsPath%, Settings, %AppName%_Path
  760.         return %SelectedFileName%
  761.     }
  762. else
  763.     BreakFocus = 0
  764.     return  %StartPath%
  765.    
  766. }
  767.  
  768.  
  769. StartXBMCAtWinLogon()
  770. {
  771.     menu, tray, ToggleCheck, Start XBMC When Windows Starts
  772.     if (StartAtWinLogon = 0)
  773.         StartAtWinLogon = 1 ;enable. load xbmc
  774.     else
  775.         StartAtWinLogon = 0 ;disable. don't load
  776.        
  777.         IniWrite, %StartAtWinLogon%, %SettingsPath%, Settings, StartAtWinLogon
  778.         return
  779. }
  780.  
  781. StartXBMCAtWinResume()
  782. {
  783.     menu, tray, ToggleCheck, Start XBMC When Windows Resumes from Sleep
  784.     if (StartAtWinResume = 0)
  785.         StartAtWinResume = 1 ;enable. load xbmc
  786.     else
  787.         StartAtWinResume = 0 ;disable. don't load
  788.        
  789.         IniWrite, %StartAtWinResume%, %SettingsPath%, Settings, StartAtWinResume
  790.         return
  791. }
  792.  
  793. DisableFocusTemporarily()
  794. {
  795.     menu, tray, ToggleCheck, Disable Focus Temporarily [Win+F9]
  796.     if (DisableFocusTemporarily = 0)
  797.         DisableFocusTemporarily = 1 ;disable focus
  798.     else
  799.         DisableFocusTemporarily = 0 ;enable focus
  800.    
  801.     }
  802.  
  803.  
  804.  
  805. DisableFocusOnExternalPlayer()
  806. {
  807.     ExternalPlayerRunning = 0
  808.     SplitPath, ExternalPlayerPath, playername
  809.     Process, exist, %playername%
  810.     If (ErrorLevel >= 1)
  811.         ExternalPlayerRunning = 1
  812.    
  813.     if (PreventFocusApps = 1)
  814.     {
  815.         global appsname
  816.         if (FileExist(App1))
  817.             {SplitPath, App1, appsname
  818.             ;if (appsname <> "")
  819.             Process, exist, %appsname%
  820.             If (ErrorLevel >= 1)
  821.             ExternalPlayerRunning = 1
  822.             }
  823.        
  824.         if (FileExist(App2))
  825.             {SplitPath, App2, appsname
  826.             ;if (appsname <> "")
  827.             Process, exist, %appsname%
  828.             If (ErrorLevel >= 1)
  829.             ExternalPlayerRunning = 1
  830.             }
  831.        
  832.         if (FileExist(App3))
  833.             {SplitPath, App3, appsname
  834.             ;if (appsname <> "")
  835.             Process, exist, %appsname%
  836.             If (ErrorLevel >= 1)
  837.             ExternalPlayerRunning = 1
  838.             }
  839.     }
  840.    
  841.     if (PreventFocusApps_1 = 1)
  842.     {
  843.         global appsname
  844.         if (FileExist(App4))
  845.             {SplitPath, App4, appsname
  846.             ;if (appsname <> "")
  847.             Process, exist, %appsname%
  848.             If (ErrorLevel >= 1)
  849.             ExternalPlayerRunning = 1
  850.             }
  851.        
  852.         if (FileExist(App5))
  853.             {SplitPath, App5, appsname
  854.             ;if (appsname <> "")
  855.             Process, exist, %appsname%
  856.             If (ErrorLevel >= 1)
  857.             ExternalPlayerRunning = 1
  858.             }
  859.        
  860.         if (FileExist(App6))
  861.             {SplitPath, App6, appsname
  862.             ;if (appsname <> "")
  863.             Process, exist, %appsname%
  864.             If (ErrorLevel >= 1)
  865.             ExternalPlayerRunning = 1
  866.             }
  867.     }
  868.    
  869. }
  870.  
  871.  
  872.  
  873. CheckFocusOnce()
  874. {
  875.     menu, tray, ToggleCheck, Check Focus Only Once
  876.     if (FocusOnce = 0)
  877.         FocusOnce = 1 ;enable. focus only once
  878.     else
  879.         FocusOnce = 0 ;disable. keep focussing
  880.        
  881.         IniWrite, %FocusOnce%, %SettingsPath%, Settings, FocusOnce
  882.         return
  883. }
  884.  
  885.  
  886.  
  887. ForceCloseXBMC()
  888. {
  889.     menu, tray, ToggleCheck,Force Close XBMC on Suspend
  890.     if (ForceClose = 0)
  891.         ForceClose = 1 ;enable
  892.     else
  893.         ForceClose = 0 ;disable
  894.        
  895.         IniWrite, %ForceClose%, %SettingsPath%, Settings, ForceClose
  896.         return
  897. }
  898.  
  899.  
  900.  
  901. SetStartExplorer()
  902. {
  903.     menu, tray, ToggleCheck,Start Windows Explorer when XBMC is closed
  904.     if (StartExplorer = 0)
  905.         {
  906.             StartExplorer = 1 ;enable
  907.             SetPressWinKey() ;turn off send win key option as using both is pointless, windows 8 explorer starts with the start menu anyway
  908.         }
  909.     else
  910.         StartExplorer = 0 ;disable
  911.                
  912.         IniWrite, %StartExplorer%, %SettingsPath%, Settings, StartExplorer
  913.         return
  914. }
  915.  
  916. SetPressWinKey()
  917. {
  918.     menu, tray, ToggleCheck,Send Windows Key when XBMC is closed
  919.     if (PressWinKey = 0)
  920.         {
  921.             PressWinKey = 1 ;enable
  922.             SetStartExplorer()  ;turn off start explorer option as explorer must be running anyway
  923.            
  924.             Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  925.             If (ErrorLevel = 0) ;if not running
  926.             WinKeySent = 1 ;prevent win key from being sent immediately after setting is changed if XBMC is not running now
  927.         }
  928.     else
  929.         PressWinKey = 0 ;disable
  930.                
  931.         IniWrite, %PressWinKey%, %SettingsPath%, Settings, PressWinKey
  932.         return
  933. }
  934.  
  935.  
  936.  
  937. SetStartApps()
  938. {
  939.     menu, tray, ToggleCheck, Start First Group Applications with XBMC Launcher
  940.     if (StartApps = 0)
  941.         StartApps = 1 ;enable.
  942.     else
  943.         StartApps = 0 ;disable.
  944.        
  945.         IniWrite, %StartApps%, %SettingsPath%, Settings, StartApps
  946.        
  947.     menu, tray, ToggleCheck, Start Second Group Applications with XBMC Launcher
  948.     if (StartApps_1 = 0)
  949.         StartApps_1 = 1 ;enable.
  950.     else
  951.         StartApps_1 = 0 ;disable.
  952.        
  953.         IniWrite, %StartApps_1%, %SettingsPath%, Settings, StartApps_1
  954.         return
  955. }
  956.  
  957.  
  958. SetPreventFocusApps()
  959. {
  960.     menu, tray, ToggleCheck, First Group Apps Prevent Focus
  961.     if (PreventFocusApps = 0)
  962.         PreventFocusApps = 1 ;enable.
  963.     else
  964.         PreventFocusApps = 0 ;disable.
  965.        
  966.         IniWrite, %PreventFocusApps%, %SettingsPath%, Settings, PreventFocusApps
  967.        
  968.     menu, tray, ToggleCheck, Second Group Apps Prevent Focus
  969.     if (PreventFocusApps_1 = 0)
  970.         PreventFocusApps_1 = 1 ;enable.
  971.     else
  972.         PreventFocusApps_1 = 0 ;disable.
  973.        
  974.         IniWrite, %PreventFocusApps_1%, %SettingsPath%, Settings, PreventFocusApps_1
  975.         return
  976. }
  977.  
  978. SetShutdownAction() ;function to set shutdown
  979. {
  980.     BreakFocus = 1
  981.     ShutdownAction := GetSettings("Shutdown", "u")
  982.     global S1
  983.     global S2
  984.     global S3
  985.    
  986.    
  987.     Gui, Add, GroupBox, x1 y4 w350 h111 +Center, Select XBMC Shutdown Menu Action
  988.     Gui, Add, Radio,  % ( ShutdownAction = "u" ? "Checked" : "" ) " x10 y40 w70 h30 vS1" , Shutdown
  989.     Gui, Add, Radio,  % ( ShutdownAction = "s" ? "Checked" : "" ) " x140 y40 w70 h30 vS2" , Sleep
  990.     Gui, Add, Radio,  % ( ShutdownAction = "h" ? "Checked" : "" ) " x250 y40 w70 h30 vS3" , Hibernate
  991.     Gui, Add, Button, x125 y78 w100 h30 , Apply
  992.     Gui, Show, w352 h121, Select XBMC Shutdown Menu Action
  993.     return
  994.  
  995.     ButtonApply:
  996.     global newlabel
  997.    Gui Submit, NoHide
  998.    Gui Destroy
  999.    If S1
  1000.     {
  1001.       Result = u
  1002.       newlabel = Shutdown
  1003.     }
  1004.    If S2
  1005.     {
  1006.       Result = s
  1007.       newlabel = Sleep
  1008.     }
  1009.    If S3
  1010.     {
  1011.       Result = h
  1012.       newlabel = Hibernate
  1013.     }
  1014.    
  1015.     IniWrite, %result%, %SettingsPath%, Settings, Shutdown
  1016.     MsgBox, 36, Modify XBMC Shutdown Menu Text, Do you want to change the Shutdown menu text also?
  1017.     ifMsgBox Yes
  1018.     {
  1019.         ModifyShutdownLabel(newLabel)
  1020.         IniWrite, %newLabel%, %SettingsPath%, Settings, ShutdownLabel
  1021.     }
  1022.     GuiClose:
  1023.     Gui, Destroy
  1024.     BreakFocus = 0
  1025.     Return
  1026. }
  1027.  
  1028.  
  1029.  
  1030. ChangeShell()
  1031. {
  1032.     RegRead, ShellName, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell
  1033.     SplitPath, ShellName, ShellName
  1034.        
  1035.     If ShellName != XBMCLauncher.exe
  1036.     {  
  1037.         ShellName = Explorer.exe
  1038.     }
  1039.    
  1040.     BreakFocus = 1
  1041.     global SH1
  1042.     global SH2
  1043.     global shelln := RTrim(ShellName, "`.exe")
  1044.     global old_shellname := "Change Windows Shell [Current Shell - " . shelln . "]"
  1045.        
  1046.     Gui, Add, GroupBox, x1 y4 w250 h111 +Center, Change Windows Shell
  1047.     Gui, Add, Radio,  % ( ShellName = "Explorer.exe" ? "Checked" : "" ) " x10 y40 w70 h30 vSH1" , Explorer
  1048.     Gui, Add, Radio,  % ( ShellName = "XBMCLauncher.exe" ? "Checked" : "" ) " x140 y40 w100 h30 vSH2" , XBMCLauncher
  1049.     Gui, Add, Button, x75 y78 w100 h30 , Save
  1050.     Gui, Show, w252 h121, Change Windows Shell
  1051.     return
  1052.    
  1053.                
  1054.    
  1055.     ButtonSave:
  1056.     Result = "Explorer.exe"
  1057.    Gui Submit, NoHide
  1058.    Gui Destroy
  1059.    If SH1
  1060.       {Result = Explorer.exe
  1061.       shelln = Explorer
  1062.       }
  1063.    If SH2
  1064.       {Result = %A_WorkingDir%\XBMCLauncher.exe
  1065.       shelln = XBMCLauncher
  1066.       }
  1067.      
  1068.     RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell, %Result%
  1069.     new_shellname = Change Windows Shell [Current Shell - %shelln%]
  1070.    
  1071.     if (old_shellname != new_shellname)
  1072.         {
  1073.             menu, tray, rename, %old_shellname%, %new_shellname%
  1074.         }
  1075.        
  1076.     Gui1Close:
  1077.     Gui, Destroy
  1078.     BreakFocus = 0
  1079.     Return
  1080. }
  1081.  
  1082.  
  1083. MonitorCustomShutdown()
  1084. {
  1085.     ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  1086.     if (ShutdownButtonClicked = 1)
  1087.     {  
  1088.        
  1089.            
  1090.         Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  1091.         If (ErrorLevel = 0) ; If it is closed
  1092.         {
  1093.             ShutdownAction := GetSettings("Shutdown", "u")
  1094.             IniWrite, 0, %SettingsPath%, Settings, ShutdownButtonClicked
  1095.             sleep 1000 ;wait one second
  1096.            
  1097.             if (ShutdownAction = "u") ;shutdown
  1098.                 {
  1099.                                        
  1100.                     objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" A_ComputerName "\root\cimv2")
  1101.                     For objOperatingSystem in objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
  1102.                     ;Caption := objOperatingSystem.Caption , OSArchitecture := objOperatingSystem.OSArchitecture, CSDVersion  := objOperatingSystem.CSDVersion, Version :=  objOperatingSystem.Version
  1103.     ;Msgbox %  Caption "`n" OSArchitecture  "`n"  CSDVersion "`n"  Version
  1104.                     Version :=  objOperatingSystem.Version
  1105.                     ;MsgBox %Version%
  1106.                     if (Version >= 6.2) ; if windows 8
  1107.                         ;MsgBox hybrid
  1108.                         run, Shutdown.exe -s -hybrid -f -t 00, ,Hide
  1109.                     else
  1110.                         ;MsgBox full
  1111.                         Shutdown, 5 ;shutdown = 1, force = 4
  1112.                 }
  1113.                
  1114.             if (ShutdownAction = "r") ;reboot
  1115.                 {
  1116.                 Shutdown, 6 ;reboot = 2, force = 4
  1117.                 }
  1118.                    
  1119.             if (ShutdownAction = "s")   ;sleep
  1120.                 {
  1121.                 DllCall("PowrProf\SetSuspendState", "int", 0)
  1122.                 }
  1123.                
  1124.             if (ShutdownAction = "h")   ;hibernate
  1125.                 {
  1126.                 DllCall("PowrProf\SetSuspendState", "int", 1)
  1127.                 }
  1128.         }
  1129.     }
  1130. }
  1131.  
  1132.  
  1133.  
  1134. StartExplorer()
  1135. {
  1136.     ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  1137.     if (StartExplorer = 1 and Suspending = 0 and ShutdownButtonClicked = 0) ;if not suspending
  1138.     {
  1139.         Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  1140.         If (ErrorLevel = 0) ;if not running
  1141.    
  1142.         Process, Exist, explorer.exe ; check to see if explorer.exe is running
  1143.         If (ErrorLevel = 0)
  1144.         Run,  %A_WinDir%\Explorer.exe, %A_WinDir%
  1145.        
  1146.     }
  1147.    
  1148. }
  1149.  
  1150. PressWinKey()
  1151. {
  1152.     ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  1153.     if (PressWinKey = 1 and Suspending = 0 and ShutdownButtonClicked = 0) ;if not suspending
  1154.     {
  1155.         Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  1156.         If (ErrorLevel = 0) ;if not running
  1157.         {      
  1158.             Process, Exist, explorer.exe ; check to see if explorer.exe is running
  1159.             If (ErrorLevel >= 1) ;If running
  1160.             {
  1161.                 If (WinKeySent = 0)
  1162.                 SendInput {Lwin}
  1163.                 WinKeySent = 1 ;prevents an infinite loop of win key presses
  1164.             }
  1165.            
  1166.         }
  1167.         else
  1168.         {
  1169.             WinKeySent = 0 ;reset WinKeySent if XBMC is opened again so that it will resend on next exit
  1170.         }
  1171.     }
  1172.    
  1173. }
  1174.  
  1175. SetStartupDelay()
  1176. {
  1177.     BreakFocus = 1
  1178.     currentstartupdelay := StartupDelay // 1000
  1179.     if currentstartupdelay is not number
  1180.         currentstartupdelay = 0
  1181.    
  1182.     InputBox, StartDelay, XBMCLauncher - Specify Startup Delay, Specify the delay  in seconds for XBMC to start., , , , , , , , %currentstartupdelay%
  1183.  
  1184.     If ErrorLevel ; If cancel was pressed
  1185.         {
  1186.             ;MsgBox cancel
  1187.         }
  1188.     else
  1189.         {
  1190.             If StartDelay is not number
  1191.                 {
  1192.                 StartDelay = 0
  1193.                 }
  1194.             Else
  1195.                 {
  1196.                 StartDelay := StartDelay * 1000
  1197.                 }
  1198.        
  1199.                 IniWrite, %StartDelay%, %SettingsPath%, Settings, StartupDelay
  1200.                 StartupDelay := StartDelay
  1201.                 startdelaynew := StartupDelay // 1000
  1202.                 startdelayold_name = Change Startup Delay [%currentstartupdelay% sec]
  1203.                 startdelaynew_name = Change Startup Delay [%startdelaynew% sec]
  1204.                                
  1205.                 if (startdelayold_name != startdelaynew_name)
  1206.                 {
  1207.                     menu, tray, rename, %startdelayold_name%, %startdelaynew_name%
  1208.                 }
  1209.                
  1210.                    
  1211.         }
  1212.     BreakFocus = 0 
  1213. }
  1214.  
  1215. return
  1216.  
  1217.  
  1218.  
  1219.  
  1220. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HANDLE KEYBOARD SHORTCUTS FOR GREEN START BUTTON <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1221.  
  1222. #F9::
  1223. DisableFocusTemporarily()
  1224. return
  1225.  
  1226. $!F4::
  1227. IfWinActive, ahk_class XBMC ; check to see if xbmc.exe is running
  1228.     {
  1229.     Send s
  1230.     return
  1231.     }
  1232. IfWinNotActive, ahk_class XBMCLauncher
  1233.     Send !{F4}
  1234.     return 
  1235.        
  1236. #F10:: ;show traymenu
  1237. DetectHiddenWindows, on
  1238. WinExist( "AHK_Pid " DllCall("GetCurrentProcessId") ) ; make this script's main window the last found window
  1239. WinActivate ; even though it's hidden, the target script's main window must be active for the menu to open
  1240. SendMessage, 0x404, 0, 0x205 ; AHK_NOTIFYICON = 0x404, WM_RBUTTONUP = 0x205
  1241. return
  1242.  
  1243. #f11:: ; Turn off Display Screen
  1244. ;Run,%A_WinDir%\System32\rundll32.exe user32.dll`,LockWorkStation
  1245. Sleep 1000
  1246. SendMessage 0x112, 0xF170, 2,,Program Manager
  1247. return
  1248.  
  1249.  
  1250. #!Enter:: ; Win+Alt+Enter shortcut key
  1251.  
  1252. LaunchApplication(XBMCPath)
  1253. ;Sleep, 2000
  1254. WinActivate, ahk_class XBMC
  1255. FocussedOnce = 0
  1256. LaunchApplication(iMONPath)
  1257. LaunchApplication(XBMConiMONPath)
  1258. Sleep, 5000
  1259. WinActivate, ahk_class XBMC
  1260.  
  1261. WinGet, Style, Style, ahk_class XBMC
  1262.     if (Style & 0xC00000)  ;Detects if XBMC has a title bar.
  1263.     {
  1264.         Send {VKDC}  ;Maximize XBMC to fullscreen mode if its in a window mode.
  1265.     }
  1266.     Return
  1267.  
  1268.  
  1269.         SetTitleMatchMode 2
  1270.         #IfWinActive XBMC ahk_class XBMC ; XBMC detection for XBMC/GSB Home Screen action.
  1271.         #!Enter::
  1272.         WinGet, Style, Style, ahk_class XBMC
  1273.         if (Style & 0xC00000)  ;Detects if XBMC has a title bar.
  1274.         {
  1275.                 Send {VKDC}  ;Maximize XBMC to fullscreen mode if its in a window mode.
  1276.         }
  1277.         WinMaximize ;Maximize XBMC if Windowed.
  1278.         send, ^!{VK74} ; if XBMC is Active (GSB Home Jump will activate)
  1279.         Return
  1280.         #IfWinActive ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement