Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * * * Compile_AHK SETTINGS BEGIN * * *
- [AHK2EXE]
- Exe_File=%In_Dir%\XBMCLauncher.exe
- Created_Date=1
- [VERSION]
- Set_Version_Info=1
- Company_Name=baijuxavior@gmail.com
- File_Description=Customize XBMC Startup
- File_Version=2.2.0.0
- Inc_File_Version=0
- Internal_Name=XBMCLauncher
- Legal_Copyright=C@P Baiju Xavior
- Original_Filename=XBMCLauncher
- Product_Name=XBMCLauncher
- Product_Version=2.2.0.0
- [ICONS]
- Icon_1=%In_Dir%\XBMCLauncher.ahk_1.ico
- Icon_2=%In_Dir%\XBMCLauncher.ahk_1.ico
- * * * Compile_AHK SETTINGS END * * *
- */
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Warn ; Recommended for catching common errors.
- #SingleInstance ignore ; create only one running instance
- #Include tf.ahk ; include file manipulation
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- DllCall("CreateMutex", "uint", 0, "int", false, "str", "xbmc_launcher_mutex") ; create a mutex to find whether the application is already running while installation.
- ProgFiles32() ;get 32 bit program files folder
- {
- EnvGet, ProgFiles32, ProgramFiles(x86)
- if ProgFiles32 = ; Probably not on a 64-bit system.
- EnvGet, ProgFiles32, ProgramFiles
- Return %ProgFiles32%
- }
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GLOBAL VARIABLES DECLARATION AND DEFAULT VALUES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- Global ProgFiles := ProgFiles32() ;Program files path
- global SettingsPath := A_AppData . "\XBMCLauncher\Settings.ini"
- global XBMCPath := ProgFiles . "\xbmc\xbmc.exe"
- global XBMConiMONPath := ProgFiles . "\xbmc-on-imon-v0.1.9.5\xbmconimon.exe"
- global iMONPath := ProgFiles . "\SoundGraph\iMON\iMON.exe"
- global version = 2.2
- global FocusDelay := GetSettings("Delay", 10000)
- global FocusOnce := GetSettings("FocusOnce", 0)
- global DisableFocusTemporarily = 0
- global FocussedOnce = 0
- global FocusCount = 0
- global ForceClose := GetSettings("ForceClose", 0)
- global StartExplorer := GetSettings("StartExplorer", 1)
- global ShowShutdownMenu := GetSettings("Shutdown", 0)
- global ShutdownAction := GetSettings("Shutdown", "u")
- global ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
- global EditDialogButton := GetSettings("EditDialogButtonMenu", 0)
- global ExternalPlayerPath := GetSettings("ExternalPlayer_Path", ProgFiles . "\ArcSoft\TotalMedia Theatre 5\uMCEPlayer5.exe")
- global ExternalPlayerRunning = 0
- global DVBViewerPath := GetSettings("DVBViewer_Path", ProgFiles . "\DVBViewer\dvbviewer.exe")
- global DVBViewerRunning = 0
- global DVBViewerGetStatus := GetSettings("DVBViewerGetStatus", 0)
- global DVBViewerSize = 0
- global DVBViewerActive = 0
- global Suspending = 0
- global StartupDelay := GetSettings("StartupDelay", 0)
- XBMCPath := GetSettings("XBMC_Path", XBMCPath)
- XBMConiMONPath := GetSettings("XBMConiMON_Path", XBMConiMONPath)
- iMONPath := GetSettings("iMON_Path", iMONPath)
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CREATE MENU ITEMS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- fdelay := FocusDelay // 1000 ; variable to show mwnu name with delay
- sdelay := StartupDelay // 1000
- IfExist, %A_WorkingDir%\XBMCLauncher.ico
- Menu, Tray, Icon, %A_WorkingDir%\XBMCLauncher.ico ; create tray icon.
- Menu, Tray, add, Start XBMC [Win+Alt+Enter], MenuStartXBMCHandler
- Menu, Tray, add, Change Startup Delay [%sdelay% sec], MenuSetStartupDelayHandler
- Menu, Tray, add
- Menu, Tray, add, Change Focus Delay [%fdelay% sec], MenuSetFocusDelayHandler
- Menu, Tray, add, Disable Focus Temporarily [Win+F9], MenuDisableFocusHandler
- Menu, Tray, UnCheck, Disable Focus Temporarily [Win+F9]
- Menu, Tray, add, Check Focus Only Once, MenuCheckFocusOnceHandler
- Menu, Tray, UnCheck, Check Focus Only Once
- Menu, Tray, add ;add separator
- if (ShowShutdownMenu <> 0)
- Menu, Tray, add, Set Shutdown Action (for confluence skin only), MenuSetShutdownActionHandler
- Menu, Tray, add, Force Close XBMC on Suspend, MenuForceCloseXBMCHandler
- Menu, Tray, UnCheck, Force Close XBMC on Suspend
- Menu, Tray, add, Start Windows Explorer when XBMC is closed, MenuStartExplorerHandler
- Menu, Tray, UnCheck, Start Windows Explorer when XBMC is closed
- Menu, Tray, add ;add separator
- Menu, Tray, add, Change Windows Shell, MenuChangeShellHandler
- Menu, Tray, add ;add separator
- Menu, Tray, add, Set XBMC Path, MenuSetXBMCPathHandler
- Menu, Tray, add, Set XBMConiMON Path, MenuSetXBMConiMONPathHandler
- Menu, Tray, add, Set iMON Path, MenuSetiMONPathHandler
- Menu, Tray, add, Set External Player Path (for focus disable), MenuSetExternalPlayerHandler
- Menu, Tray, add
- Menu, Tray, add, Set DVBViewer Path (for focus disable), MenuSetDVBViewerHandler
- Menu, Tray, add, Ignore if DVBViewer is minimized, MenuCheckDVBViewerGetStatusHandler
- Menu, Tray, UnCheck, Ignore if DVBViewer is minimized
- Menu, Tray, add
- Menu, Tray, add, Open XBMC Programs Folder, MenuOpenXBMCFolderHandler
- Menu, Tray, add, Open XBMC Application Data Folder, MenuOpenXBMCAppFolderHandler
- Menu, Tray, add
- Menu, Tray, add, About XBMCLauncher, MenuAboutHandler
- Menu, Tray, add
- Menu, tray, NoStandard
- Menu, tray, Standard
- if (FocusOnce = 1)
- Menu, Tray, Check, Check Focus Only Once
- if (ForceClose = 1)
- Menu, Tray, Check, Force Close XBMC on Suspend
- if (StartExplorer = 1)
- Menu, Tray, Check, Start Windows Explorer when XBMC is closed
- if (DVBViewerGetStatus = 1)
- Menu, Tray, Check, Ignore if DVBViewer is minimized
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROMPT FOR XBMC IF NOT FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- IfNotExist, %XBMCPath% ; if xbmc.exe not exists, prompt to select xbmc.exe manually
- {
- MsgBox, 36, Select XBMC.exe, Could not locate XBMC executable file. Do you want to select the file manually?, 10
- ifMsgBox Yes
- {
- XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
- if (ShowShutdownMenu <> 0)
- { SplitPath, XBMCPath, ,newpath
- FileCopy, %A_WorkingDir%\ShutdownAction.exe, %newpath%, 1
- FileCopy, %A_WorkingDir%\ShutdownAction.py, %newpath%, 1
- FileCopy, %A_WorkingDir%\CloseXBMC.exe, %newpath%, 1
- FileCopy, %A_WorkingDir%\CloseXBMC.py, %newpath%, 1
- FileCopy, %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p\DialogButtonMenu_Backup.xml, 0
- FileCopy, %A_WorkingDir%\DialogButtonMenu.xml, %newpath%\addons\skin.confluence\720p, 1
- newdialogfile = %newpath%\addons\skin.confluence\720p\DialogButtonMenu.xml
- oldline2 = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
- newline2 = <onclick>XBMC.RunScript(%newpath%\ShutdownAction.py)</onclick>
- TF_Replace("!" . newdialogfile, oldline2, newline2)
- oldline2 = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
- newline2 = <onclick>XBMC.RunScript(%newpath%\CloseXBMC.py)</onclick>
- TF_Replace("!" . newdialogfile, oldline2, newline2)
- IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
- IniWrite, 1, %SettingsPath%, Settings, UninstallDeleteFile
- }
- }
- }
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LAUNCH APPLICATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- Sleep %StartupDelay%
- LaunchApplication(XBMCPath)
- WinWait,XBMC,,6 ; wait 6 seconds
- WinActivate, ahk_class XBMC ; activate and bring to front.
- LaunchApplication(iMONPath)
- LaunchApplication(XBMConiMONPath)
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MODIFY SHUTDOWN DIALOG BUTTON MENU - FOR CUSTOM MENU ONLY <<<<<<<<<<<<<<<<
- If (EditDialogButton = 1)
- {
- SplitPath, XBMCPath, , xbmcdir
- dialogfile = %xbmcdir%\addons\skin.confluence\720p\DialogButtonMenu.xml
- IfExist, %dialogfile%
- {
- oldline = <onclick>XBMC.RunScript(ShutdownAction.py)</onclick>
- newline = <onclick>XBMC.RunScript(%xbmcdir%\ShutdownAction.py)</onclick>
- TF_Replace("!" . dialogfile, oldline, newline)
- oldline = <onclick>XBMC.RunScript(CloseXBMC.py)</onclick>
- newline = <onclick>XBMC.RunScript(%xbmcdir%\CloseXBMC.py)</onclick>
- TF_Replace("!" . dialogfile, oldline, newline)
- IniWrite, 0, %SettingsPath%, Settings, EditDialogButtonMenu
- }
- }
- ModifyShutdownLabel(ShutdownLabel)
- {
- SplitPath, XBMCPath, , dir
- dialogfile1 = %dir%\addons\skin.confluence\720p\DialogButtonMenu.xml
- IfExist, %dialogfile1%
- { lbl := GetSettings("ShutdownLabel", "Shutdown")
- if (lbl <> ShutdownLabel)
- {
- oldline1 = <label>%lbl%</label>
- newline1 = <label>%ShutdownLabel%</label>
- TF_Replace("!" . dialogfile1, oldline1, newline1)
- }
- }
- }
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START XBMC ON WINDOWS RESUME FROM HIBERNATION OR SLEEP <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- OnMessage(0x218, "WM_POWERBROADCAST")
- WM_POWERBROADCAST(wParam, lParam)
- {
- If (wParam=4) ;suspend
- {
- Suspending = 1 ;System is suspending. Do not start Explorer.
- if (ForceClose = 1) ; force close xbmc
- {
- Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
- If (ErrorLevel >= 1) ; If it is running
- {
- Process, Close, %ErrorLevel%
- Process, WaitClose, %ErrorLevel%
- sleep 1000
- }
- }
- }
- If (wParam=7) ;on resuming from suspend state
- {
- LaunchApplication(XBMConiMONPath)
- Sleep %StartupDelay%
- ;sleep 5000 ;delay xbmc load by 5 seconds to initialize the sound card.
- LaunchApplication(XBMCPath)
- if (DisableFocusTemporarily = 1)
- {
- DisableFocusTemporarily() ;re enable focus
- }
- Suspending = 0
- FocussedOnce = 0
- }
- }
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TIMER DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- SetTimer, MonitorEvents, 500
- MonitorEvents:
- KeepFocus()
- CheckDVBViewerRunning()
- GetDVBViewerSize()
- StartExplorer()
- MonitorCustomShutdown()
- DisableFocusOnExternalPlayer()
- DisableFocusOnDVBViewer()
- return
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SYSTEM TRAY MENU HANDLERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- MenuStartXBMCHandler:
- {
- LaunchApplication(XBMCPath)
- Sleep, 2000
- WinActivate, ahk_class XBMC
- FocussedOnce = 0
- }
- return
- MenuSetStartupDelayHandler:
- SetStartupDelay()
- return
- MenuSetFocusDelayHandler:
- SetFocusDelay()
- return
- MenuDisableFocusHandler:
- DisableFocusTemporarily()
- return
- MenuCheckFocusOnceHandler:
- CheckFocusOnce()
- return
- MenuSetXBMCPathHandler:
- XBMCPath := SaveApplicationPath("XBMC", XBMCPath)
- return
- MenuSetXBMConiMONPathHandler:
- XBMConiMONPath := SaveApplicationPath("XBMConiMON", XBMConiMONPath)
- return
- MenuSetiMONPathHandler:
- iMONPath := SaveApplicationPath("iMON", iMONPath)
- return
- MenuSetExternalPlayerHandler:
- ExternalPlayerPath := SaveApplicationPath("ExternalPlayer", ExternalPlayerPath)
- return
- MenuSetDVBViewerHandler:
- DVBViewerPath := SaveApplicationPath("DVBViewer", DVBViewerPath)
- return
- MenuCheckDVBViewerGetStatusHandler:
- CheckDVBViewerGetStatus()
- return
- MenuSetShutdownActionHandler:
- SetShutdownAction()
- return
- MenuForceCloseXBMCHandler:
- ForceCloseXBMC()
- return
- MenuStartExplorerHandler:
- SetStartExplorer()
- return
- MenuChangeShellHandler:
- ChangeShell()
- return
- MenuOpenXBMCAppFolderHandler:
- {
- appfolder := A_AppData . "\XBMC"
- ifexist, %appfolder%
- run %appfolder%
- }
- return
- MenuOpenXBMCFolderHandler:
- {
- SplitPath, XBMCPath, , xbmcfolder
- IfExist, %xbmcfolder%
- run %xbmcfolder%
- }
- return
- MenuAboutHandler:
- {
- MsgBox XBMCLauncher %version% `n`nAn application to customize your XBMC HTPC. `nDesigned and programmed by baijuxavior@gmail.com
- }
- return
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- KeepFocus()
- {
- if (FocusDelay = 0 or DisableFocusTemporarily = 1 or ExternalPlayerRunning = 1 or DVBViewerActive = 1)
- {
- FocusCount = 0
- return
- }
- FocusCount := FocusCount + 1
- If (FocusCount = (FocusDelay * 2) // 1000)
- {
- FocusCount = 0
- if (FocusOnce = 0)
- {
- SendFocus()
- return
- }
- if (FocusOnce = 1 and FocussedOnce = 0)
- {
- SendFocus()
- FocussedOnce = 1
- }
- }
- }
- SendFocus()
- {
- Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
- If (ErrorLevel >= 1)
- WinActivate, ahk_class XBMC
- }
- GetSettings(SettingsName, DefaultValue) ;Get settings from Settings.ini file
- {
- If FileExist(SettingsPath)
- {
- IniRead, result, %SettingsPath%, Settings, %SettingsName%, %DefaultValue%
- return %result%
- }
- else
- return %DefaultValue%
- }
- SetFocusDelay() ;function to Change Focus Delay
- {
- currentdelay := FocusDelay // 1000
- if currentdelay is not number
- currentdelay = 5
- 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%
- If ErrorLevel ; If cancel was pressed
- {
- ;MsgBox cancel
- }
- else
- {
- If Delay is not number
- {
- Delay = 5000
- }
- Else
- {
- Delay := Delay * 1000
- }
- IniWrite, %Delay%, %SettingsPath%, Settings, Delay
- FocusDelay := Delay
- fdelaynew := FocusDelay // 1000
- old_name = Change Focus Delay [%currentdelay% sec]
- new_name = Change Focus Delay [%fdelaynew% sec]
- if (old_name != new_name)
- {
- menu, tray, rename, %old_name%, %new_name%
- }
- }
- }
- LaunchApplication(AppPath) ; function to start applications
- {
- SplitPath, AppPath, FileName ;get filename without path
- Process, Exist, %FileName% ; check to see if 'FileName' is running
- If (ErrorLevel = 0) ;if not running
- {
- if FileExist(AppPath)
- {
- run %AppPath%
- }
- Else
- {
- ;traytip, Message, %AppPath% not found, 5, 1
- }
- }
- Else ; file already running
- {
- ;traytip, Message, %FileName% already running, 5, 1
- }
- }
- SaveApplicationPath(AppName, StartPath)
- {
- FileSelectFile, SelectedFileName,1 ,%StartPath%, Select %AppName%.exe, *.exe
- if SelectedFileName !=
- {
- IniWrite, %SelectedFileName%, %SettingsPath%, Settings, %AppName%_Path
- return %SelectedFileName%
- }
- else
- return %StartPath%
- }
- DisableFocusTemporarily()
- {
- menu, tray, ToggleCheck, Disable Focus Temporarily [Win+F9]
- if (DisableFocusTemporarily = 0)
- DisableFocusTemporarily = 1 ;disable focus
- else
- DisableFocusTemporarily = 0 ;enable focus
- }
- DisableFocusOnExternalPlayer()
- {
- SplitPath, ExternalPlayerPath, playername
- Process, exist, %playername%
- If (ErrorLevel >= 1)
- ExternalPlayerRunning = 1
- else
- ExternalPlayerRunning = 0
- }
- CheckFocusOnce()
- {
- menu, tray, ToggleCheck, Check Focus Only Once
- if (FocusOnce = 0)
- FocusOnce = 1 ;enable. focus only once
- else
- FocusOnce = 0 ;disable. keep focussing
- IniWrite, %FocusOnce%, %SettingsPath%, Settings, FocusOnce
- return
- }
- ForceCloseXBMC()
- {
- menu, tray, ToggleCheck,Force Close XBMC on Suspend
- if (ForceClose = 0)
- ForceClose = 1 ;enable
- else
- ForceClose = 0 ;disable
- IniWrite, %ForceClose%, %SettingsPath%, Settings, ForceClose
- return
- }
- SetStartExplorer()
- {
- menu, tray, ToggleCheck,Start Windows Explorer when XBMC is closed
- if (StartExplorer = 0)
- StartExplorer = 1 ;enable
- else
- StartExplorer = 0 ;disable
- IniWrite, %StartExplorer%, %SettingsPath%, Settings, StartExplorer
- return
- }
- SetShutdownAction() ;function to set shutdown
- {
- ShutdownAction := GetSettings("Shutdown", "u")
- global S1
- global S2
- global S3
- Gui, Add, GroupBox, x1 y4 w350 h111 +Center, Select XBMC Shutdown Menu Action
- Gui, Add, Radio, % ( ShutdownAction = "u" ? "Checked" : "" ) " x10 y40 w70 h30 vS1" , Shutdown
- Gui, Add, Radio, % ( ShutdownAction = "s" ? "Checked" : "" ) " x140 y40 w70 h30 vS2" , Sleep
- Gui, Add, Radio, % ( ShutdownAction = "h" ? "Checked" : "" ) " x250 y40 w70 h30 vS3" , Hibernate
- Gui, Add, Button, x125 y78 w100 h30 , Apply
- Gui, Show, w352 h121, Select XBMC Shutdown Menu Action
- return
- ButtonApply:
- global newlabel
- Gui Submit, NoHide
- Gui Destroy
- If S1
- {
- Result = u
- newlabel = Shutdown
- }
- If S2
- {
- Result = s
- newlabel = Sleep
- }
- If S3
- {
- Result = h
- newlabel = Hibernate
- }
- IniWrite, %result%, %SettingsPath%, Settings, Shutdown
- MsgBox, 36, Modify XBMC Shutdown Menu Text, Do you want to change the Shutdown menu text also?
- ifMsgBox Yes
- {
- ModifyShutdownLabel(newLabel)
- IniWrite, %newLabel%, %SettingsPath%, Settings, ShutdownLabel
- }
- GuiClose:
- Gui, Destroy
- Return
- }
- ChangeShell()
- {
- RegRead, CurrentShell, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell
- global SH1
- global SH2
- SplitPath, CurrentShell, ShellName
- If ShellName != XBMCLauncher.exe
- {
- ShellName = Explorer.exe
- }
- Gui, Add, GroupBox, x1 y4 w250 h111 +Center, Change Windows Shell
- Gui, Add, Radio, % ( ShellName = "Explorer.exe" ? "Checked" : "" ) " x10 y40 w70 h30 vSH1" , Explorer
- Gui, Add, Radio, % ( ShellName = "XBMCLauncher.exe" ? "Checked" : "" ) " x140 y40 w100 h30 vSH2" , XBMCLauncher
- Gui, Add, Button, x75 y78 w100 h30 , Save
- Gui, Show, w252 h121, Change Windows Shell
- return
- ButtonSave:
- Result = "Explorer.exe"
- Gui Submit, NoHide
- Gui Destroy
- If SH1
- Result = Explorer.exe
- If SH2
- Result = %A_WorkingDir%\XBMCLauncher.exe
- RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, Shell, %Result%
- Gui1Close:
- Gui, Destroy
- Return
- }
- MonitorCustomShutdown()
- {
- ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
- if (ShutdownButtonClicked = 1)
- {
- Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
- If (ErrorLevel = 0) ; If it is closed
- {
- ShutdownAction := GetSettings("Shutdown", "u")
- IniWrite, 0, %SettingsPath%, Settings, ShutdownButtonClicked
- sleep 1000 ;wait one second
- if (ShutdownAction = "u") ;shutdown
- {
- Shutdown, 5 ;shutdown = 1, force = 4
- }
- if (ShutdownAction = "r") ;reboot
- {
- Shutdown, 6 ;reboot = 2, force = 4
- }
- if (ShutdownAction = "s") ;sleep
- {
- DllCall("PowrProf\SetSuspendState", "int", 0)
- }
- if (ShutdownAction = "h") ;hibernate
- {
- DllCall("PowrProf\SetSuspendState", "int", 1)
- }
- }
- }
- }
- StartExplorer()
- {
- ShutdownButtonClicked := GetSettings("ShutdownButtonClicked", 0)
- if (StartExplorer = 1 and Suspending = 0 and ShutdownButtonClicked = 0) ;if not suspending
- {
- Process, Exist, xbmc.exe ; check to see if xbmc.exe is running
- If (ErrorLevel = 0) ;if not running
- Process, Exist, explorer.exe ; check to see if explorer.exe is running
- If (ErrorLevel = 0)
- Run, %A_WinDir%\Explorer.exe, %A_WinDir%
- }
- }
- SetStartupDelay()
- {
- currentstartupdelay := StartupDelay // 1000
- if currentstartupdelay is not number
- currentstartupdelay = 0
- InputBox, StartDelay, XBMCLauncher - Specify Startup Delay, Specify the delay in seconds for XBMC to start., , , , , , , 10, %currentstartupdelay%
- If ErrorLevel ; If cancel was pressed
- {
- ;MsgBox cancel
- }
- else
- {
- If StartDelay is not number
- {
- StartDelay = 0
- }
- Else
- {
- StartDelay := StartDelay * 1000
- }
- IniWrite, %StartDelay%, %SettingsPath%, Settings, StartupDelay
- StartupDelay := StartDelay
- startdelaynew := StartupDelay // 1000
- startdelayold_name = Change Startup Delay [%currentstartupdelay% sec]
- startdelaynew_name = Change Startup Delay [%startdelaynew% sec]
- if (startdelayold_name != startdelaynew_name)
- {
- menu, tray, rename, %startdelayold_name%, %startdelaynew_name%
- }
- }
- }
- return
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DVBViewer FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- CheckDVBViewerGetStatus()
- {
- menu, tray, ToggleCheck, Ignore if DVBViewer is minimized
- if (DVBViewerGetStatus = 0)
- DVBViewerGetStatus = 1 ;enable. check DVBViewer window size
- else
- DVBViewerGetStatus = 0 ;disable. dont check DVBViewer window size
- IniWrite, %DVBViewerGetStatus%, %SettingsPath%, Settings, DVBViewerGetStatus
- return
- }
- GetDVBViewerSize()
- {
- WinGet, DVBViewerPresentSize, MinMax, ahk_class TfrmMain
- if DVBViewerPresentSize < 0
- DVBViewerSize = 0
- if DVBViewerPresentSize = 0
- DVBViewerSize = 1
- if DVBViewerPresentSize = 1
- DVBViewerSize = 2
- }
- CheckDVBViewerRunning()
- {
- SplitPath, DVBViewerPath, viewername
- Process, exist, %viewername%
- If (ErrorLevel >= 1)
- DVBViewerRunning = 1
- Else
- DVBViewerRunning = 0
- }
- DisableFocusOnDVBViewer()
- {
- IF (DVBViewerRunning = 1 and DVBViewerGetStatus = 0)
- DVBViewerActive = 1
- Else If (DVBViewerRunning = 1 and DVBViewerGetStatus = 1)
- {
- If (DVBViewerSize > 0)
- DVBViewerActive = 1
- Else
- DVBViewerActive = 0
- }
- Else
- DVBViewerActive = 0
- ; MsgBox Running:%DVBViewerRunning% Status:%DVBViewerGetStatus% Size:%DVBViewerSize% Active:%DVBViewerActive% Delay:%FocusDelay% Temp:%DisableFocusTemporarily% External:%ExternalPlayerRunning%
- }
- ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HANDLE KEYBOARD SHORTCUTS FOR GREEN START BUTTON <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- #F9::
- DisableFocusTemporarily()
- return
- $!F4::
- IfWinActive, ahk_class XBMC ; check to see if xbmc.exe is running
- {
- Send s
- return
- }
- IfWinNotActive, ahk_class XBMCLauncher
- Send !{F4}
- return
- #F10:: ;show traymenu
- DetectHiddenWindows, on
- WinExist( "AHK_Pid " DllCall("GetCurrentProcessId") ) ; make this script's main window the last found window
- WinActivate ; even though it's hidden, the target script's main window must be active for the menu to open
- SendMessage, 0x404, 0, 0x205 ; AHK_NOTIFYICON = 0x404, WM_RBUTTONUP = 0x205
- return
- #!Enter:: ; Win+Alt+Enter shortcut key
- LaunchApplication(XBMCPath)
- Sleep, 2000
- WinActivate, ahk_class XBMC
- FocussedOnce = 0
- LaunchApplication(iMONPath)
- LaunchApplication(XBMConiMONPath)
- Sleep, 5000
- WinActivate, ahk_class XBMC
- WinGet, Style, Style, ahk_class XBMC
- if (Style & 0xC00000) ;Detects if XBMC has a title bar.
- {
- Send {VKDC} ;Maximize XBMC to fullscreen mode if its in a window mode.
- }
- Return
- SetTitleMatchMode 2
- #IfWinActive XBMC ahk_class XBMC ; XBMC detection for XBMC/GSB Home Screen action.
- #!Enter::
- WinGet, Style, Style, ahk_class XBMC
- if (Style & 0xC00000) ;Detects if XBMC has a title bar.
- {
- Send {VKDC} ;Maximize XBMC to fullscreen mode if its in a window mode.
- }
- WinMaximize ;Maximize XBMC if Windowed.
- send, ^!{VK74} ; if XBMC is Active (GSB Home Jump will activate)
- Return
- #IfWinActive ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement