Switch between XBMC and WMC with remote
#1
All:

I told myself I was going to post this in case anyone could benefit from it. I created an AUTOIT script that allows me to use my the 8 and 9 buttons on my cheap MCE remote to switch between XBMC and WMC. I still use WMC for scheduling recordings, and my wife, frankly, still uses WMC as she is not ready for a learning curve.

In this script, pressing 8 will close XMBC if open, and start WMC. Pressing 9 will do vice versa. It's not pretty as I put it together quickly; nevertheless, it could benefit someone else. I have the built .exe if anyone wants it.

Code:
; capture and pass along a keypress
HotKeySet("{NUMPAD8}", "captureNumpad8")
HotKeySet("{NUMPAD9}", "captureNumpad9")

while 1  
      Sleep(100)     
WEnd
  
  Func captureNumpad8()
      ; deactivate key capture temporarily
      HotKeySet("{NUMPAD8}")
      ;#RequireAdmin
      ;; set title match mode to exact
      ;Opt("WinTitleMatchMode", 3)
      ;if winexists("XBMC") Then
        ;  winactivate("XBMC")
      ; Else
        ;  Send("{NUMPAD8}")
      ;EndIf

      ; close the ProcessClose
      if (ProcessExists("xbmc.exe")) Then ; 0 if process is not found
         ; close the process
         SplashTextOn("Closing the process", "Closing the process")
         Local $closeResult = ProcessClose("xbmc.exe")
         ProcessWaitClose("XBMC.exe", 10)
         SplashTextOn("Process is closed", "Process is closed")
         Opt("WinTitleMatchMode", 3)
         if winexists("XBMC") Then
           winactivate("XBMC")
            WinSetState("XBMC", "", @SW_MAXIMIZE)
         EndIf

      EndIf
      if (not ProcessExists("xbmc.exe")) Then ; 0 if process is not found
         SplashTextOn("Opening the process", "Opening the process")
         ; open the other process
         Run("C:\Windows\ehome\ehshell.exe");
         SplashTextOn("Process is opened", "Process is opened")
         Opt("WinTitleMatchMode", 3)
         if winexists("Windows Media Center") Then
           winactivate("Windows Media Center")
            WinSetState("Windows Media Center", "", @SW_MAXIMIZE)
         EndIf

      EndIf


      ; reactivate key capture
      HotKeySet("{NUMPAD8}", "captureNumpad8")
      SplashOff()
   EndFunc
  
     Func captureNumpad9()
      ; deactivate key capture temporarily
      HotKeySet("{Numpad9}")
      ;#RequireAdmin
      ;; set title match mode to exact
      ;Opt("WinTitleMatchMode", 3)
      ;if winexists("XBMC") Then
        ;  winactivate("XBMC")
      ; Else
        ;  Send("{Numpad9}")
      ;EndIf

      ; close the ProcessClose
      if (ProcessExists("ehshell.exe")) Then ; 0 if process is not found
         ; close the process
         SplashTextOn("Closing the process", "Closing the process")
         Local $closeResult = ProcessClose("ehshell.exe")
         ProcessWaitClose("ehshell.exe", 10)
         SplashTextOn("Process is closed", "Process is closed")
      EndIf
      if (not ProcessExists("ehshell.exe")) Then ; 0 if process is not found
         SplashTextOn("Opening the process", "Opening the process")
         ; open the other process
         Run("C:\Program Files (x86)\XBMC\xbmc.exe");
         SplashTextOn("Process is opened", "Process is opened")
        
      EndIf


      ; reactivate key capture
      HotKeySet("{Numpad9}", "captureNumpad9")
      SplashOff()
EndFunc
Reply

Logout Mark Read Team Forum Stats Members Help
Switch between XBMC and WMC with remote0