Win How-to: Default to XBMC when resuming from sleep
#1
Lightbulb 
IF YOU'RE USING A CEC ADAPTER - PLEASE SEE POST 2 FIRST

Hi,

I have been using XBMC as my new media player for a couple of weeks now and loving it. Over this time I have been tweaking and customising it to work efficiently for my scenario.

My goal has always been to have the process of media playback to be as seamless and intuitive as possible.. also known as “able to pass the Girlfriend/Wife test.

So the main purpose of my HTPC is media playback (XMBC/Kodi). I also use it to stream events live (web browser) or stream gameplay (Steam In-Home Streaming) on the odd occasion and because of this, sometimes would leave the computer in a state other than “XBMC ready”.

So what’s the goal here? To automate the system to enter a “XBMC ready state” every time it resumes from sleep, regardless of how it was left before entering sleep.

Please note: At the time of writing this the was written, version 14 (Kodi) release was buggy and therefor this was created while using V13.2 (XBMC). Please make the appropriate changes if you wish this to work with Kodi.

Step 1 - Download the required tools.
Put these files in a directory together. You can title this directory to suit you but for this how-to we will call it c:\XBMCmode

KeyStuff.exe ( http://www.richpasco.org/utilities/keystuff.html )
CMDOW.exe ( http://www.commandline.co.uk/cmdow/ )

Step 2 - Enable keyboard shortcut for XBMC.
-Locate a shortcut to XBMC and enter it’s properties. Easiest for me way (Windows 8.1) was to pin to taskbar. Right click the pinned icon, right click XBMC and then select properties.
-Click in to the ‘Shortcut Key’ field and press CTRL + ALT + 1

We later use KeyStuff.exe to send the keystrokes to the computer opening XBMC. By using this option in the shortcut we avoid the problem of opening multiple instances of XBMC.

Step 3 - Create the task, triggered by computer resuming from sleep.
-Put your computer to sleep then wake the computer up.
-Open ‘event viewer’, select ‘System Logs’ under ‘Windows Logs’ and find “Power-Troubleshooter” The event ID will be 1.
-Select this event and press “Attach task to this event”
-Give the task a title of your choice.
-Move on to ‘Action’ and select “Start a program”
-Browse to c:\XBMCmode\KeyStuff.exe and press OK
-in ‘Add argument’ field enter “ctrl-alt-1”
-Press OK to complete step 3.

We have now created a scheduled task that is triggered when the computer resumes from sleep. It will action KeyStuff to input the key press of CTRL + ALT + 1, which will open XBMC via the shortcut.

Step 4 - Focus XBMC to screen
If XBMC wasn’t running to begin with, our task sequence would load XBMC for us and it would be visible on the screen. If XBMC was running but the computer was on the desktop or left in another application, triggering the shortcut does NOT focus XBMC to the screen. We now use CMDOW to focus XBMC.

-Enter the properties your task sequence that you created in step 3.
-Go to actions tab and click ‘new’.
-Browse to c\XBMCmode\CMDOW.exe and click OK.
-Add arguments “XBMC /ACT”
-Press OK.

This makes the window with the title “XBMC” active (/ACT) and to the front of the screen.

That’s it! Now regardless of what state the computer was in before it went into sleep mode, when resuming from sleep the computer will either load XBMC or bring it to the main focus of the screen. No need to reach for the keyboard just use the CEC controls on your TV remote.
Reply
#2
OPTION 2 - For people using CEC.

Found a bug where XBMC wouldn't re-initiate the CEC control using the above method.

-Removed BOTH actions from the task schedule.
-Added new action to run C:\restartXBMC.cmd

Inside restartXBMC.cmd is the following:

@echo off
taskill /im XBMC.exe /f
ping localhost -n 3
start "" "c:\Program Files (x86)\XBMC\XBMC.EXE"
ping localhost -n 3
exit



It's not very elegant but it does the job.

Kills existing XBMC session.
Waits for this to happen.
Starts XBMC.
Waits for this to happen.
Closes CMD window.

Thoughts?
Reply
#3
I've been using a small, free app called "Hibernate Trigger" for years to exit XBMC before sleep and start it after sleep. It will do so regardless if XBMC is open. It was useful for resolving some performance problems when sleep happened with XBMC active. I still use it because XBMC updates the video library on startup, so it is always updated for me

It works well, but I don't ever leave an instance of XBMC running in a window or minimized, always full screen. If I use other windows applications, I exit XBMC.

I also recall another similar tool someone had specifically for XBMC discussed in the forums, but I can't recall its name.

EDIT: "XBMC Launcher" is the tool I was remembering. Haven't used it, but it may overlap with what you are doing.
http://forum.kodi.tv/showthread.php?tid=136798
Reply
#4
Great suggestions Whitebelly. Seems XBMC Launcher covers all basis.

Hopefully someone can use all the info in this thread to suit their needs.
Reply
#5
Hi,
on Windows you can start applications pinned to the taskbar via [WindowsKey]+[Position], e.g. if Kodi is the first (or only) pinned icon you press [Windows]+[1]. So no need for a custom hotkey there.

Just wanted to let you know.
Wink
Reply
#6
That's correct but you don't want to break it if you accidentally drag your pinned item over.

I've found CEC was breaking because XBMC has to be the focus while the connection to the CEC adapter is established. Once something else loads or is triggers it takes the focus away from XBMC and breaks that connection.
Reply
#7
Could not retrieve directory as not connected ,but I was connected
Reply

Logout Mark Read Team Forum Stats Members Help
How-to: Default to XBMC when resuming from sleep0