locked
How to wake Windows 8 tablet from sleep?

    Question

  • I've been redirected to this forum from this thread. I am technically coding a Windows 8 desktop app that has a requirement of letting a user to set a schedule to wake the tablet from sleep at a predefined time and run a program/command. From my experience, even though I could set a schedule via the built-in Task Scheduler, such schedule did not wake my test tablet. In the meantime I also ran a test with one of the alarm clock Metro apps from the app store, which was able to wake my tablet from sleep at a predefined time and play a sound.

    So my question is how do you make a Metro app wake computer from sleep at a certain time?

    PS. I'm coding using C++, so hopefully I'll be able to apply your technique to a desktop app.

    Sunday, July 21, 2013 10:14 PM

Answers

  • Programmatic wake up is not supported for Windows Store apps. I'm not familiar enough with desktop app power management to comment. That would be better asked in the desktop forums.

    --Rob

    • Marked as answer by ahmd0 Monday, July 22, 2013 8:55 PM
    Monday, July 22, 2013 4:04 PM
    Owner

All replies

  • Not sure why you were directed here for a desktop app question. I think Pavel was confused (I think he's done that before thinking that the Windows Store app forums are general Windows 8 forums and not Windows Store app specific).

    Windows Store apps cannot generically wake the computer from sleep.  They can schedule toasts or tile notifications to run at specific times. That is most likely what your alarm app did. Desktop apps can raise immediate toasts, but they cannot schedule them.

    See Toast notification overview

    --Rob

    Monday, July 22, 2013 1:48 AM
    Owner
  • Programmatic wake up is not supported for Windows Store apps. I'm not familiar enough with desktop app power management to comment. That would be better asked in the desktop forums.

    --Rob

    • Marked as answer by ahmd0 Monday, July 22, 2013 8:55 PM
    Monday, July 22, 2013 4:04 PM
    Owner
  • Programmatic wake up is not supported for Windows Store apps. I'm not familiar enough with desktop app power management to comment. That would be better asked in the desktop forums.

    --Rob

    Wow, that is very interesting. For a desktop app one could use CreateWaitableTimer followed by SetWaitableTimer that will let you specify whether to wake the system or not (last parameter.) But, Pavel is correct, I'm asking about Windows Store apps here.

    So, Rob, in the world of Windows Store apps, there must be some way to wake the system. I mean how would you write an alarm clock app? Pardon my lack of knowledge of the terminology that Microsoft uses, but there must be at least some sort of a "push notification" to do that. Is it what you mean by "toast notification"?

    I have an alarm clock app right now on my Lenovo tablet that wakes it from sleep at the time that I set it up for and then plays music. So if it can play music why can't it be set up to run a file?

    Monday, July 22, 2013 7:19 PM
  • Hi ahmd0,

    Please take a look at the documentation I linked in my previous post. Your alarm app is probably scheduling a toast notification which can include audio as part of the notification. This is fire-and-forget from the app's point of view: it schedules the toast but doesn't get called back to handle it itself.

    Push notifications are similar, but are external to the system rather than being scheduled. A cloud server passes the notification data to the Windows Notification Server which pushes it to the OS. Push notifications can show toasts or update tiles without running the app.

    Windows Store apps are sandboxed and have their lifetime managed to reduce power use. They cannot arbitrarily choose when to run. They run only when the user chooses to do so. They can also schedule some items to run in the background (see Supporting your app with background tasks ), but that doesn't appear to be relevant to your scenario and doesn't provide features you can carry back to your desktop app.

    --Rob

    Monday, July 22, 2013 7:56 PM
    Owner
  • Thanks again, Rob. I marked your first reply as an answer. I did some research and you're correct. Metro style apps indeed are very limited and are not allowed to wake system on timer. I presented my findings in this desktop thread.

    I've never tried programming Windows Store apps but I honestly feel for you guys. How can you do anything with them -- apart from a simple Angry Birds app? It is so limiting. I develop for iOS and I thought options were limited there. But now it seems like Microsoft made it even more tight. Anyway, that is not the platform that I will be developing for in my future.

    Monday, July 22, 2013 9:02 PM