Advertisement
Guest User

Untitled

a guest
Oct 19th, 2012
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.66 KB | None | 0 0
  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=2.2.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=2.2.0.0
  18. [ICONS]
  19. Icon_1=%In_Dir%\XBMCLauncher.ahk_1.ico
  20. Icon_2=%In_Dir%\XBMCLauncher.ahk_1.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 = 2.2
  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 ForceClose := GetSettings("ForceClose", 0)
  58. global StartExplorer := GetSettings("StartExplorer", 1)
  59. global ShowShutdownMenu := GetSettings("Shutdown", 0)
  60. global ShutdownAction := GetSettings("Shutdown", "u")
  61. global ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  62. global EditDialogButton := GetSettings("EditDialogButtonMenu", 0)
  63. global ExternalPlayerPath := GetSettings("ExternalPlayer_Path", ProgFiles . "\ArcSoft\TotalMedia Theatre 5\uMCEPlayer5.exe")
  64. global ExternalPlayerRunning = 0
  65. global DVBViewerPath := GetSettings("DVBViewer_Path", ProgFiles . "\DVBViewer\dvbviewer.exe")
  66. global DVBViewerRunning = 0
  67. global DVBViewerGetStatus := GetSettings("DVBViewerGetStatus", 0)
  68. global DVBViewerSize = 0
  69. global DVBViewerActive = 0
  70. global Suspending = 0
  71. global StartupDelay := GetSettings("StartupDelay", 0)
  72.  
  73. XBMCPath := GetSettings("XBMC_Path", XBMCPath)
  74. XBMConiMONPath := GetSettings("XBMConiMON_Path", XBMConiMONPath)
  75. iMONPath := GetSettings("iMON_Path", iMONPath)
  76.  
  77.  
  78.  
  79. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CREATE MENU ITEMS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  80.  
  81.  
  82.  
  83. fdelay := FocusDelay // 1000 ; variable to show mwnu name with delay
  84. sdelay := StartupDelay // 1000
  85. IfExist, %A_WorkingDir%\XBMCLauncher.ico
  86. Menu, Tray, Icon, %A_WorkingDir%\XBMCLauncher.ico ; create tray icon.
  87.  
  88. Menu, Tray, add, Start XBMC [Win+Alt+Enter], MenuStartXBMCHandler
  89. Menu, Tray, add, Change Startup Delay [%sdelay% sec], MenuSetStartupDelayHandler
  90. Menu, Tray, add
  91. Menu, Tray, add, Change Focus Delay [%fdelay% sec], MenuSetFocusDelayHandler
  92. Menu, Tray, add, Disable Focus Temporarily [Win+F9], MenuDisableFocusHandler
  93. Menu, Tray, UnCheck, Disable Focus Temporarily [Win+F9]
  94. Menu, Tray, add, Check Focus Only Once, MenuCheckFocusOnceHandler
  95. Menu, Tray, UnCheck, Check Focus Only Once
  96. Menu, Tray, add ;add separator
  97. if (ShowShutdownMenu <> 0)
  98. Menu, Tray, add, Set Shutdown Action (for confluence skin only), MenuSetShutdownActionHandler
  99. Menu, Tray, add, Force Close XBMC on Suspend, MenuForceCloseXBMCHandler
  100. Menu, Tray, UnCheck, Force Close XBMC on Suspend
  101. Menu, Tray, add, Start Windows Explorer when XBMC is closed, MenuStartExplorerHandler
  102. Menu, Tray, UnCheck, Start Windows Explorer when XBMC is closed
  103. Menu, Tray, add ;add separator
  104. Menu, Tray, add, Change Windows Shell, MenuChangeShellHandler
  105. Menu, Tray, add ;add separator
  106. Menu, Tray, add, Set XBMC Path, MenuSetXBMCPathHandler
  107. Menu, Tray, add, Set XBMConiMON Path, MenuSetXBMConiMONPathHandler
  108. Menu, Tray, add, Set iMON Path, MenuSetiMONPathHandler
  109. Menu, Tray, add, Set External Player Path (for focus disable), MenuSetExternalPlayerHandler
  110. Menu, Tray, add
  111. Menu, Tray, add, Set DVBViewer Path (for focus disable), MenuSetDVBViewerHandler
  112. Menu, Tray, add, Ignore if DVBViewer is minimized, MenuCheckDVBViewerGetStatusHandler
  113. Menu, Tray, UnCheck, Ignore if DVBViewer is minimized
  114. Menu, Tray, add
  115. Menu, Tray, add, Open XBMC Programs Folder, MenuOpenXBMCFolderHandler
  116. Menu, Tray, add, Open XBMC Application Data Folder, MenuOpenXBMCAppFolderHandler
  117. Menu, Tray, add
  118. Menu, Tray, add, About XBMCLauncher, MenuAboutHandler
  119. Menu, Tray, add
  120. Menu, tray, NoStandard
  121. Menu, tray, Standard
  122.  
  123. if (FocusOnce = 1)
  124. Menu, Tray, Check, Check Focus Only Once
  125. if (ForceClose = 1)
  126. Menu, Tray, Check, Force Close XBMC on Suspend
  127.  
  128. if (StartExplorer = 1)
  129. Menu, Tray, Check, Start Windows Explorer when XBMC is closed
  130.  
  131. if (DVBViewerGetStatus = 1)
  132. Menu, Tray, Check, Ignore if DVBViewer is minimized
  133.  
  134.  
  135.  
  136. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROMPT FOR XBMC IF NOT FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  137.  
  138.  
  139.  
  140. IfNotExist, %XBMCPath% ; if xbmc.exe not exists, prompt to select xbmc.exe manually
  141. {
  142. MsgBox, 36, Select XBMC.exe, Could not locate XBMC executable file. Do you want to select the file manually?, 10
  143. ifMsgBox Yes
  144. {
  145. XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
  146. if (ShowShutdownMenu <> 0)
  147. { SplitPath, XBMCPath, ,newpath
  148. FileCopy, %A_WorkingDir%\ShutdownAction.exe, %newpath%, 1
  149. FileCopy, %A_WorkingDir%\ShutdownAction.py, %newpath%, 1
  150. FileCopy, %A_WorkingDir%\CloseXBMC.exe, %newpath%, 1
  151. FileCopy, %A_WorkingDir%\CloseXBMC.py, %newpath%, 1
  152. FileCopy, %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p\DialogButtonMenu_Backup.xml, 0
  153. FileCopy, %A_WorkingDir%\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p, 1
  154.  
  155. newdialogfile = %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml
  156. oldline2 = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
  157. newline2 = <onclick>XBMC.RunScript(%newpath%\ShutdownAction.py)</onclick>
  158. TF_Replace("!" . newdialogfile, oldline2, newline2)
  159. oldline2 = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
  160. newline2 = <onclick>XBMC.RunScript(%newpath%\CloseXBMC.py)</onclick>
  161. TF_Replace("!" . newdialogfile, oldline2, newline2)
  162. IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
  163. IniWrite, 1, %SettingsPath%, Settings, UninstallDeleteFile
  164. }
  165. }
  166. }
  167.  
  168.  
  169.  
  170. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LAUNCH APPLICATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  171.  
  172. Sleep %StartupDelay%
  173. LaunchApplication(XBMCPath)
  174. WinWait,XBMC,,6 ; wait 6 seconds
  175. WinActivate, ahk_class XBMC ; activate and bring to front.
  176. LaunchApplication(iMONPath)
  177. LaunchApplication(XBMConiMONPath)
  178.  
  179.  
  180. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MODIFY SHUTDOWN DIALOG BUTTON MENU - FOR CUSTOM MENU ONLY <<<<<<<<<<<<<<<<
  181.  
  182.  
  183. If (EditDialogButton = 1)
  184. {
  185.  
  186. SplitPath, XBMCPath, , xbmcdir
  187. dialogfile = %xbmcdir%\addons\skin.confluence\720p\DialogButtonMenu.xml
  188. IfExist, %dialogfile%
  189. {
  190. oldline = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
  191. newline = <onclick>XBMC.RunScript(%xbmcdir%\ShutdownAction.py)</onclick>
  192. TF_Replace("!" . dialogfile, oldline, newline)
  193. oldline = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
  194. newline = <onclick>XBMC.RunScript(%xbmcdir%\CloseXBMC.py)</onclick>
  195. TF_Replace("!" . dialogfile, oldline, newline)
  196. IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
  197. }
  198. }
  199.  
  200.  
  201.  
  202. ModifyShutdownLabel(ShutdownLabel)
  203. {
  204. SplitPath, XBMCPath, , dir
  205. dialogfile1 = %dir%\addons\skin.confluence\720p\DialogButtonMenu.xml
  206. IfExist, %dialogfile1%
  207. { lbl := GetSettings("ShutdownLabel", "Shutdown")
  208. if (lbl <> ShutdownLabel)
  209. {
  210. oldline1 = <label>%lbl%</label>
  211. newline1 = <label>%ShutdownLabel%</label>
  212. TF_Replace("!" . dialogfile1, oldline1, newline1)
  213. }
  214. }
  215. }
  216.  
  217.  
  218.  
  219.  
  220. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START XBMC ON WINDOWS RESUME FROM HIBERNATION OR SLEEP <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  221.  
  222.  
  223. OnMessage(0x218, "WM_POWERBROADCAST")
  224.  
  225. WM_POWERBROADCAST(wParam, lParam)
  226. {
  227.  
  228. If (wParam=4) ;suspend
  229. {
  230. Suspending = 1 ;System is suspending. Do not start Explorer.
  231. if (ForceClose = 1) ; force close xbmc
  232. {
  233. Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  234. If (ErrorLevel >= 1) ; If it is running
  235. {
  236. Process, Close, %ErrorLevel%
  237. Process, WaitClose, %ErrorLevel%
  238. sleep 1000
  239. }
  240. }
  241. }
  242.  
  243. If (wParam=7) ;on resuming from suspend state
  244. {
  245. LaunchApplication(XBMConiMONPath)
  246.  
  247. Sleep %StartupDelay%
  248. ;sleep 5000 ;delay xbmc load by 5 seconds to initialize the sound card.
  249.  
  250. LaunchApplication(XBMCPath)
  251.  
  252. if (DisableFocusTemporarily = 1)
  253. {
  254. DisableFocusTemporarily() ;re enable focus
  255. }
  256.  
  257. Suspending = 0
  258. FocussedOnce = 0
  259. }
  260.  
  261.  
  262. }
  263.  
  264.  
  265.  
  266.  
  267. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TIMER DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  268.  
  269.  
  270. SetTimer, MonitorEvents, 500
  271.  
  272. MonitorEvents:
  273. KeepFocus()
  274. CheckDVBViewerRunning()
  275. GetDVBViewerSize()
  276. StartExplorer()
  277. MonitorCustomShutdown()
  278. DisableFocusOnExternalPlayer()
  279. DisableFocusOnDVBViewer()
  280. return
  281.  
  282.  
  283.  
  284. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SYSTEM TRAY MENU HANDLERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  285.  
  286.  
  287. MenuStartXBMCHandler:
  288. {
  289. LaunchApplication(XBMCPath)
  290. Sleep, 2000
  291. WinActivate, ahk_class XBMC
  292. FocussedOnce = 0
  293. }
  294. return
  295.  
  296. MenuSetStartupDelayHandler:
  297. SetStartupDelay()
  298. return
  299.  
  300.  
  301. MenuSetFocusDelayHandler:
  302. SetFocusDelay()
  303. return
  304.  
  305. MenuDisableFocusHandler:
  306. DisableFocusTemporarily()
  307. return
  308.  
  309. MenuCheckFocusOnceHandler:
  310. CheckFocusOnce()
  311. return
  312.  
  313.  
  314. MenuSetXBMCPathHandler:
  315. XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
  316. return
  317.  
  318. MenuSetXBMConiMONPathHandler:
  319. XBMConiMONPath := SaveApplicationPath("XBMConiMON", XBMConiMONPath)
  320. return
  321.  
  322. MenuSetiMONPathHandler:
  323. iMONPath := SaveApplicationPath("iMON", iMONPath)
  324. return
  325.  
  326. MenuSetExternalPlayerHandler:
  327. ExternalPlayerPath := SaveApplicationPath("ExternalPlayer", ExternalPlayerPath)
  328. return
  329.  
  330. MenuSetDVBViewerHandler:
  331. DVBViewerPath := SaveApplicationPath("DVBViewer", DVBViewerPath)
  332. return
  333.  
  334. MenuCheckDVBViewerGetStatusHandler:
  335. CheckDVBViewerGetStatus()
  336. return
  337.  
  338. MenuSetShutdownActionHandler:
  339. SetShutdownAction()
  340. return
  341.  
  342. MenuForceCloseXBMCHandler:
  343. ForceCloseXBMC()
  344. return
  345.  
  346. MenuStartExplorerHandler:
  347. SetStartExplorer()
  348. return
  349.  
  350. MenuChangeShellHandler:
  351. ChangeShell()
  352. return
  353.  
  354. MenuOpenXBMCAppFolderHandler:
  355. {
  356. appfolder := A_AppData . "\XBMC"
  357. ifexist, %appfolder%
  358. run %appfolder%
  359. }
  360.  
  361. return
  362.  
  363. MenuOpenXBMCFolderHandler:
  364. {
  365. SplitPath, XBMCPath, , xbmcfolder
  366. IfExist, %xbmcfolder%
  367. run %xbmcfolder%
  368. }
  369.  
  370. return
  371.  
  372.  
  373. MenuAboutHandler:
  374. {
  375. MsgBox XBMCLauncher %version% `n`nAn application to customize your XBMC HTPC. `nDesigned and programmed by baijuxavior@gmail.com
  376. }
  377. return
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  387.  
  388.  
  389.  
  390.  
  391.  
  392. KeepFocus()
  393. {
  394. if (FocusDelay = 0 or DisableFocusTemporarily = 1 or ExternalPlayerRunning = 1 or DVBViewerActive = 1)
  395. {
  396. FocusCount = 0
  397. return
  398. }
  399.  
  400. FocusCount := FocusCount + 1
  401.  
  402.  
  403. If (FocusCount = (FocusDelay * 2) // 1000)
  404. {
  405.  
  406. FocusCount = 0
  407. if (FocusOnce = 0)
  408. {
  409. SendFocus()
  410. return
  411. }
  412.  
  413. if (FocusOnce = 1 and FocussedOnce = 0)
  414. {
  415. SendFocus()
  416. FocussedOnce = 1
  417. }
  418. }
  419.  
  420. }
  421.  
  422.  
  423. SendFocus()
  424. {
  425. Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  426. If (ErrorLevel >= 1)
  427. WinActivate, ahk_class XBMC
  428.  
  429. }
  430.  
  431.  
  432.  
  433. GetSettings(SettingsName, DefaultValue) ;Get settings from Settings.ini file
  434. {
  435.  
  436. If FileExist(SettingsPath)
  437. {
  438. IniRead, result, %SettingsPath%, Settings, %SettingsName%, %DefaultValue%
  439. return %result%
  440. }
  441. else
  442. return %DefaultValue%
  443. }
  444.  
  445.  
  446. SetFocusDelay() ;function to Change Focus Delay
  447. {
  448. currentdelay := FocusDelay // 1000
  449. if currentdelay is not number
  450. currentdelay = 5
  451.  
  452. InputBox, Delay, XBMCLauncher - Specify Time Delay, Specify the delay between refocussing of XBMC in seconds. `n `nEnter '0' seconds to prevent refocus permanently., , , , , , , 10, %currentdelay%
  453.  
  454. If ErrorLevel ; If cancel was pressed
  455. {
  456. ;MsgBox cancel
  457. }
  458. else
  459. {
  460. If Delay is not number
  461. {
  462. Delay = 5000
  463. }
  464. Else
  465. {
  466. Delay := Delay * 1000
  467. }
  468.  
  469. IniWrite, %Delay%, %SettingsPath%, Settings, Delay
  470. FocusDelay := Delay
  471. fdelaynew := FocusDelay // 1000
  472. old_name = Change Focus Delay [%currentdelay% sec]
  473. new_name = Change Focus Delay [%fdelaynew% sec]
  474.  
  475. if (old_name != new_name)
  476. {
  477. menu, tray, rename, %old_name%, %new_name%
  478. }
  479.  
  480.  
  481. }
  482. }
  483.  
  484.  
  485.  
  486. LaunchApplication(AppPath) ; function to start applications
  487. {
  488. SplitPath, AppPath, FileName ;get filename without path
  489. Process, Exist, %FileName% ; check to see if 'FileName' is running
  490. If (ErrorLevel = 0) ;if not running
  491. {
  492. if FileExist(AppPath)
  493. {
  494. run %AppPath%
  495. }
  496. Else
  497. {
  498. ;traytip, Message, %AppPath% not found, 5, 1
  499. }
  500. }
  501. Else ; file already running
  502. {
  503. ;traytip, Message, %FileName% already running, 5, 1
  504. }
  505. }
  506.  
  507.  
  508. SaveApplicationPath(AppName, StartPath)
  509. {
  510. FileSelectFile, SelectedFileName,1 ,%StartPath%, Select %AppName%.exe, *.exe
  511. if SelectedFileName !=
  512. {
  513. IniWrite, %SelectedFileName%, %SettingsPath%, Settings, %AppName%_Path
  514. return %SelectedFileName%
  515. }
  516. else
  517. return %StartPath%
  518.  
  519. }
  520.  
  521.  
  522.  
  523.  
  524. DisableFocusTemporarily()
  525. {
  526. menu, tray, ToggleCheck, Disable Focus Temporarily [Win+F9]
  527. if (DisableFocusTemporarily = 0)
  528. DisableFocusTemporarily = 1 ;disable focus
  529. else
  530. DisableFocusTemporarily = 0 ;enable focus
  531.  
  532. }
  533.  
  534.  
  535.  
  536. DisableFocusOnExternalPlayer()
  537. {
  538. SplitPath, ExternalPlayerPath, playername
  539. Process, exist, %playername%
  540. If (ErrorLevel >= 1)
  541. ExternalPlayerRunning = 1
  542. else
  543. ExternalPlayerRunning = 0
  544. }
  545.  
  546.  
  547.  
  548. CheckFocusOnce()
  549. {
  550. menu, tray, ToggleCheck, Check Focus Only Once
  551. if (FocusOnce = 0)
  552. FocusOnce = 1 ;enable. focus only once
  553. else
  554. FocusOnce = 0 ;disable. keep focussing
  555.  
  556. IniWrite, %FocusOnce%, %SettingsPath%, Settings, FocusOnce
  557. return
  558. }
  559.  
  560.  
  561.  
  562. ForceCloseXBMC()
  563. {
  564. menu, tray, ToggleCheck,Force Close XBMC on Suspend
  565. if (ForceClose = 0)
  566. ForceClose = 1 ;enable
  567. else
  568. ForceClose = 0 ;disable
  569.  
  570. IniWrite, %ForceClose%, %SettingsPath%, Settings, ForceClose
  571. return
  572. }
  573.  
  574.  
  575.  
  576. SetStartExplorer()
  577. {
  578. menu, tray, ToggleCheck,Start Windows Explorer when XBMC is closed
  579. if (StartExplorer = 0)
  580. StartExplorer = 1 ;enable
  581. else
  582. StartExplorer = 0 ;disable
  583.  
  584. IniWrite, %StartExplorer%, %SettingsPath%, Settings, StartExplorer
  585. return
  586. }
  587.  
  588.  
  589.  
  590. SetShutdownAction() ;function to set shutdown
  591. {
  592. ShutdownAction := GetSettings("Shutdown", "u")
  593. global S1
  594. global S2
  595. global S3
  596.  
  597.  
  598. Gui, Add, GroupBox, x1 y4 w350 h111 +Center, Select XBMC Shutdown Menu Action
  599. Gui, Add, Radio, % ( ShutdownAction = "u" ? "Checked" : "" ) " x10 y40 w70 h30 vS1" , Shutdown
  600. Gui, Add, Radio, % ( ShutdownAction = "s" ? "Checked" : "" ) " x140 y40 w70 h30 vS2" , Sleep
  601. Gui, Add, Radio, % ( ShutdownAction = "h" ? "Checked" : "" ) " x250 y40 w70 h30 vS3" , Hibernate
  602. Gui, Add, Button, x125 y78 w100 h30 , Apply
  603. Gui, Show, w352 h121, Select XBMC Shutdown Menu Action
  604. return
  605.  
  606. ButtonApply:
  607. global newlabel
  608. Gui Submit, NoHide
  609. Gui Destroy
  610. If S1
  611. {
  612. Result = u
  613. newlabel = Shutdown
  614. }
  615. If S2
  616. {
  617. Result = s
  618. newlabel = Sleep
  619. }
  620. If S3
  621. {
  622. Result = h
  623. newlabel = Hibernate
  624. }
  625.  
  626. IniWrite, %result%, %SettingsPath%, Settings, Shutdown
  627. MsgBox, 36, Modify XBMC Shutdown Menu Text, Do you want to change the Shutdown menu text also?
  628. ifMsgBox Yes
  629. {
  630. ModifyShutdownLabel(newLabel)
  631. IniWrite, %newLabel%, %SettingsPath%, Settings, ShutdownLabel
  632. }
  633. GuiClose:
  634. Gui, Destroy
  635. Return
  636. }
  637.  
  638.  
  639.  
  640. ChangeShell()
  641. {
  642.  
  643. RegRead, CurrentShell, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell
  644. global SH1
  645. global SH2
  646. SplitPath, CurrentShell, ShellName
  647.  
  648. If ShellName != XBMCLauncher.exe
  649. {
  650. ShellName = Explorer.exe
  651. }
  652.  
  653. Gui, Add, GroupBox, x1 y4 w250 h111 +Center, Change Windows Shell
  654. Gui, Add, Radio, % ( ShellName = "Explorer.exe" ? "Checked" : "" ) " x10 y40 w70 h30 vSH1" , Explorer
  655. Gui, Add, Radio, % ( ShellName = "XBMCLauncher.exe" ? "Checked" : "" ) " x140 y40 w100 h30 vSH2" , XBMCLauncher
  656. Gui, Add, Button, x75 y78 w100 h30 , Save
  657. Gui, Show, w252 h121, Change Windows Shell
  658. return
  659.  
  660. ButtonSave:
  661. Result = "Explorer.exe"
  662. Gui Submit, NoHide
  663. Gui Destroy
  664. If SH1
  665. Result = Explorer.exe
  666. If SH2
  667. Result = %A_WorkingDir%\XBMCLauncher.exe
  668.  
  669. RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell, %Result%
  670. Gui1Close:
  671. Gui, Destroy
  672. Return
  673. }
  674.  
  675.  
  676. MonitorCustomShutdown()
  677. {
  678. ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  679. if (ShutdownButtonClicked = 1)
  680. {
  681.  
  682. Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  683. If (ErrorLevel = 0) ; If it is closed
  684. {
  685. ShutdownAction := GetSettings("Shutdown", "u")
  686. IniWrite, 0, %SettingsPath%, Settings, ShutdownButtonClicked
  687. sleep 1000 ;wait one second
  688.  
  689. if (ShutdownAction = "u") ;shutdown
  690. {
  691. Shutdown, 5 ;shutdown = 1, force = 4
  692. }
  693.  
  694. if (ShutdownAction = "r") ;reboot
  695. {
  696. Shutdown, 6 ;reboot = 2, force = 4
  697. }
  698.  
  699. if (ShutdownAction = "s") ;sleep
  700. {
  701. DllCall("PowrProf\SetSuspendState", "int", 0)
  702. }
  703.  
  704. if (ShutdownAction = "h") ;hibernate
  705. {
  706. DllCall("PowrProf\SetSuspendState", "int", 1)
  707. }
  708. }
  709. }
  710. }
  711.  
  712.  
  713.  
  714. StartExplorer()
  715. {
  716. ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
  717. if (StartExplorer = 1 and Suspending = 0 and ShutdownButtonClicked = 0) ;if not suspending
  718. {
  719. Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
  720. If (ErrorLevel = 0) ;if not running
  721.  
  722. Process, Exist, explorer.exe ; check to see if explorer.exe is running
  723. If (ErrorLevel = 0)
  724. Run, %A_WinDir%\Explorer.exe, %A_WinDir%
  725.  
  726. }
  727.  
  728. }
  729.  
  730.  
  731. SetStartupDelay()
  732. {
  733. currentstartupdelay := StartupDelay // 1000
  734. if currentstartupdelay is not number
  735. currentstartupdelay = 0
  736.  
  737. InputBox, StartDelay, XBMCLauncher - Specify Startup Delay, Specify the delay in seconds for XBMC to start., , , , , , , 10, %currentstartupdelay%
  738.  
  739. If ErrorLevel ; If cancel was pressed
  740. {
  741. ;MsgBox cancel
  742. }
  743. else
  744. {
  745. If StartDelay is not number
  746. {
  747. StartDelay = 0
  748. }
  749. Else
  750. {
  751. StartDelay := StartDelay * 1000
  752. }
  753.  
  754. IniWrite, %StartDelay%, %SettingsPath%, Settings, StartupDelay
  755. StartupDelay := StartDelay
  756. startdelaynew := StartupDelay // 1000
  757. startdelayold_name = Change Startup Delay [%currentstartupdelay% sec]
  758. startdelaynew_name = Change Startup Delay [%startdelaynew% sec]
  759.  
  760. if (startdelayold_name != startdelaynew_name)
  761. {
  762. menu, tray, rename, %startdelayold_name%, %startdelaynew_name%
  763. }
  764.  
  765.  
  766. }
  767. }
  768.  
  769. return
  770.  
  771.  
  772. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DVBViewer FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  773.  
  774.  
  775. CheckDVBViewerGetStatus()
  776. {
  777. menu, tray, ToggleCheck, Ignore if DVBViewer is minimized
  778. if (DVBViewerGetStatus = 0)
  779. DVBViewerGetStatus = 1 ;enable. check DVBViewer window size
  780. else
  781. DVBViewerGetStatus = 0 ;disable. dont check DVBViewer window size
  782.  
  783. IniWrite, %DVBViewerGetStatus%, %SettingsPath%, Settings, DVBViewerGetStatus
  784. return
  785. }
  786.  
  787.  
  788.  
  789. GetDVBViewerSize()
  790. {
  791. WinGet, DVBViewerPresentSize, MinMax, ahk_class TfrmMain
  792. if DVBViewerPresentSize < 0
  793. DVBViewerSize = 0
  794. if DVBViewerPresentSize = 0
  795. DVBViewerSize = 1
  796. if DVBViewerPresentSize = 1
  797. DVBViewerSize = 2
  798. }
  799.  
  800.  
  801.  
  802. CheckDVBViewerRunning()
  803. {
  804. SplitPath, DVBViewerPath, viewername
  805. Process, exist, %viewername%
  806. If (ErrorLevel >= 1)
  807. DVBViewerRunning = 1
  808. Else
  809. DVBViewerRunning = 0
  810. }
  811.  
  812.  
  813.  
  814. DisableFocusOnDVBViewer()
  815. {
  816. IF (DVBViewerRunning = 1 and DVBViewerGetStatus = 0)
  817. DVBViewerActive = 1
  818. Else If (DVBViewerRunning = 1 and DVBViewerGetStatus = 1)
  819. {
  820. If (DVBViewerSize > 0)
  821. DVBViewerActive = 1
  822. Else
  823. DVBViewerActive = 0
  824. }
  825. Else
  826. DVBViewerActive = 0
  827.  
  828. ; MsgBox Running:%DVBViewerRunning% Status:%DVBViewerGetStatus% Size:%DVBViewerSize% Active:%DVBViewerActive% Delay:%FocusDelay% Temp:%DisableFocusTemporarily% External:%ExternalPlayerRunning%
  829. }
  830.  
  831.  
  832.  
  833. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HANDLE KEYBOARD SHORTCUTS FOR GREEN START BUTTON <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  834.  
  835. #F9::
  836. DisableFocusTemporarily()
  837. return
  838.  
  839. $!F4::
  840. IfWinActive, ahk_class XBMC ; check to see if xbmc.exe is running
  841. {
  842. Send s
  843. return
  844. }
  845. IfWinNotActive, ahk_class XBMCLauncher
  846. Send !{F4}
  847. return
  848.  
  849. #F10:: ;show traymenu
  850. DetectHiddenWindows, on
  851. WinExist( "AHK_Pid " DllCall("GetCurrentProcessId") ) ; make this script's main window the last found window
  852. WinActivate ; even though it's hidden, the target script's main window must be active for the menu to open
  853. SendMessage, 0x404, 0, 0x205 ; AHK_NOTIFYICON = 0x404, WM_RBUTTONUP = 0x205
  854. return
  855.  
  856. #!Enter:: ; Win+Alt+Enter shortcut key
  857.  
  858. LaunchApplication(XBMCPath)
  859. Sleep, 2000
  860. WinActivate, ahk_class XBMC
  861. FocussedOnce = 0
  862. LaunchApplication(iMONPath)
  863. LaunchApplication(XBMConiMONPath)
  864. Sleep, 5000
  865. WinActivate, ahk_class XBMC
  866.  
  867. WinGet, Style, Style, ahk_class XBMC
  868. if (Style & 0xC00000) ;Detects if XBMC has a title bar.
  869. {
  870. Send {VKDC} ;Maximize XBMC to fullscreen mode if its in a window mode.
  871. }
  872. Return
  873.  
  874.  
  875. SetTitleMatchMode 2
  876. #IfWinActive XBMC ahk_class XBMC ; XBMC detection for XBMC/GSB Home Screen action.
  877. #!Enter::
  878. WinGet, Style, Style, ahk_class XBMC
  879. if (Style & 0xC00000) ;Detects if XBMC has a title bar.
  880. {
  881. Send {VKDC} ;Maximize XBMC to fullscreen mode if its in a window mode.
  882. }
  883. WinMaximize ;Maximize XBMC if Windowed.
  884. send, ^!{VK74} ; if XBMC is Active (GSB Home Jump will activate)
  885. Return
  886. #IfWinActive ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement