Skip to main content

 none
How can I set a wake timer in Windows 8 Pro running on a tablet with C++? RRS feed

  • Question

  • I am trying to set a wake timer from a desktop app running on a Windows 8 Professional. How can I do this with C++? I need this to work not only on a desktop or a laptop but also on a tablet.
    Monday, June 17, 2013 3:27 AM

All replies

  • You can schedule a task and use ITaskSettings::WakeToRun to set the wake up setting.

    A Windows store app can't wake up the computer it runs. If you want to wake up a networked tablet you can check if the tablet supports wake-on-lan.



    Visual C++ MVP


    Monday, June 17, 2013 9:01 PM
    Moderator
  • Sorry for a very delayed response...

    I was able to use ITaskSettings3::put_WakeToRun(VARIANT_TRUE); with the C++ code from this page (scroll down to the bottom):
    http://msdn.microsoft.com/en-us/library/windows/desktop/hh848037%28v=vs.85%29.aspx

    It works fine if my Lenovo IdeaPad Lynx tablet is powered on, but if I press the power button (that I'm assuming puts it into a Connected Standby mode) the task does not run at the scheduled time. It runs only when I manually power on the tablet later.

    Just to be sure I tried to set a schedule in the Task Scheduler with the "Wake the computer to run this task" setting checked and also to allow it to run on DC power. The tablet didn't wake to run the task either.

    Also as a test I downloaded a Metro-style alarm clock app from the Windows store and tried setting an alarm with it. In this case, having put my tablet into sleep with the power button, the Metro app was able to play the sound at the scheduled time.

    So there must be the way (new to Windows 8 apps) to wake the tablet from sleep?

    Saturday, July 20, 2013 8:53 PM
  • > So there must be the way (new to Windows 8 apps) to wake the tablet from sleep?

    IIRC, not necessarily at all: the ability to wake by software depends on the platform. Have you tried to ask Lenovo whether and how their tablet supports this?

    -- pa

    There's no need to ask. Like I said above one of the alarm clock apps from the app store can wake that tablet up from sleep and play alarm sound. So there must be some way, right?

    Plus I know that at least another Windows 8 tablet behaved the same way. It seems like this is encoded into Windows.
    Sunday, July 21, 2013 2:24 AM
  • Thanks. I'll try to ask my question there... although again, I need it for a desktop and not a metro app.

    I'll also try to remove the answer from that reply above. I don't know who did it. I didn't mark it.

    If I get to the bottom of this I'll post an update here. Also if there's someone who has access to a Windows 8 Pro tablet, would you try to set a schedule in the Task Scheduler and see if it wake it up?

    Sunday, July 21, 2013 10:02 PM
  • This question is off topic for the Tailoring your Windows Store app for hardware and devices forum. That forum is specifically for Windows Store apps and not for desktop apps. It is also the wrong forum for scheduled notifications for Windows Store apps.

    Windows Store apps such as the Alarm app mentioned here can schedule toasts to appear at specific times. Desktop apps can raise immediate toasts, but cannot schedule toasts.

    --Rob

    Monday, July 22, 2013 1:51 AM
  • @Rob: Thanks for your comment. I was indeed asking about Windows store apps in that thread.

    @Pavel: Now I'm curious if wake from sleep is even supported on a Windows 8 desktop (I mean physical desktop computer or a laptop)?

    What happens on my Windows 8 tablet is that SetWaitableTimer API with fResume set to TRUE scceeds but it returns ERROR_NOT_SUPPORTED if one checks GetLastError -- pretty much like it says in the description.

    It may be though that this happens only if the device supports new Connected Standby mode. You can listen to what that is at this Build presentation from 2011. Fast forward to about 27m:20s. From what it sounds like all user-mode Win32 desktop apps will be simply suspended (read about Desktop Activity Moderator in Windows 8) and in despite of all their high praises for this Connected Standby mode, they will simply disallow Win32 apps to schedule resuming from sleep. Period. If so, it's pretty rotten and I surely hope that their Connected Standby doesn't migrate to any non-toy computers: desktops and laptops/notebooks.

    • Edited by ahmd0 Monday, July 22, 2013 8:52 PM Correction
    Monday, July 22, 2013 8:48 PM

  • Just tested on a win8 RTM desktop: A scheduled task will wake the machine from hibernation. This machine does not support other sleep modes under win8.

    Are wake timers enabled on your tablet? The option to enable wake timers is in Advanced power options, under Sleep.

    -- pa

    OK. That's the good news. Sleep is probably also supported on a desktop computer as well. I'm curious now about Windows 8 laptops? Especially the ones with touch screens?

    As for the wake timers, then there's no such option on this tablet:



    I believe wake timers are disabled by default.

    Monday, July 22, 2013 10:09 PM
  • On my win8 desktop wake timers were enabled by default. 


    Whereas iOS only supports few fixed models, Windows work on all sorts of machines - that's what  we love it for  ;)

    -- pa

    Monday, July 22, 2013 10:55 PM
  • On my win8 desktop wake timers were enabled by default. 

    Whereas iOS only supports few fixed models, Windows work on all sorts of machines - that's what  we love it for  ;)

    -- pa

    Yes, it looks as such on my Windows 7 desktop too. It likely means that it does not support Connected Standby.

    I agree with you about iOS, although from a standpoint of a developer that platform is way more rewarding to develop for since your apps won't break as often as they do on Windows with a multitude of hardware & settings. What I'm concerned about is that Microsoft will adopt the tablet-OS approach to their desktop OS, which will be wrong! They already partially did it with Windows 8. Hopefully they'll come to senses and reverse some of it in v.8.1. Might be my wishful thinking though ...

    Monday, July 22, 2013 11:04 PM