Can a macro tell if it has been asleep?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Can a macro tell if it has been asleep?

Post by Me_again » Thu Feb 16, 2012 9:18 pm

If a compiled macro (e.g. one that collects or sends data at regular intervals) is running on a PC that goes into sleep or hibernation mode, is there any system way for it to recognize that when it starts running again? Of course it could be constantly checking the previous timestamp but I'm wondering if there is a more sophisticated solution.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 17, 2012 12:51 am

Of course it could be constantly checking the previous timestamp but I'm wondering if there is a more sophisticated solution.
Is this what you're NOT looking for? It works, and its not very sophisticated.

Code: Select all

VBSTART
VBEND

Label>Loop
  VBEval>timer,first_time
  Wait>1
  VBEval>timer-%first_time%,second_time
  If>Second_Time>10
    MDL>Second_Time=%Second_Time%  I must have been sleeping.
  EndIf
Goto>Loop

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Feb 17, 2012 2:49 pm

Correct, that's not what I am looking for :) I was wondering if there is some accessible windows flag/indicator/variable that indicates a return from sleep/hibernation.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 17, 2012 4:11 pm

How about a test for process logonui.exe?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 21, 2012 5:00 am

Hmmm, good thought, but I suspect that doesn't run unless the system is setup to require a re-login. The solution appears to be Windows Power Management Events and I found a script for another automation program that monitors those notifications.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts