Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Auto power on
#1
Is possible auto power on the computer if the system was stopped in hibernation?
#2
Use a scheduled task, or

Function WakeUpAfter
Code:
Copy      Help
;\
function# wakeUpAfterSeconds [flags] ;;flags: 1 turn on display, 2 sleep now, 4 hibernate now

;Waits wakeUpAfterSeconds seconds and then temporarily wakes up the computer
;from sleep (suspend, standby) or hibernate. When the caller macro ends, but
;not earlier than after 2 minutes, Windows again puts the computer into the
;sleep/hibernate state. However it doesn't if you use the physical mouse or
;keyboard. On some systems it also doesn't if a macro uses mouse/keyboard.
;This function must be called BEFORE putting the computer into the sleep state.
;Returns 1 on success, 0 on failure (eg if it is not supported by the hardware).


;EXAMPLE
;;put computer into sleep state, wait 1 minute, wake up, turn on display,
;;tell Windows to sleep again when the macro ends or after 2 minutes (which
;;is longer) unless you use mouse/keyboard during that time
;WakeUpAfter 1*60 1|2



long t=-wakeUpAfterSeconds*10000000 ;;negative - from now, positive - absolute
__Handle h=CreateWaitableTimer(0 0 0)
if(!SetWaitableTimer(h +&t 0 0 0 1)) ret ;;the 1 tells to wake up computer
if(flags&6) shutdown iif(flags&2 5 4)
wait 0 H h ;;wait for the timer
rep(30) 1; if(IsLoggedOn=1) break ;;wait for default desktop
1

;tell Windows to not sleep while the macro is running, and optionally to turn on display
SetThreadExecutionState ES_CONTINUOUS|iif(flags&1 ES_DISPLAY_REQUIRED|ES_SYSTEM_REQUIRED 0)

ret 1
#3

Wait, is this going to turn on your computer automatically or just your monitor? Or am I just misunderstanding what this function does? I didn't think it was possible to turn your computer on with QM. Confusedhock:
Taking on Quick Macros one day at a time
#4
Turns on computer and optionally monitor. The computer must not be shut down but only in sleep or hibernate state.
#5

Oh okay, after reading more inside the function thats what I figured. So this wouldn't work if my computer was actually shut off, would it?


Example: Have a macro scheduled to turn on my computer every morning at 7:30 AM.
Taking on Quick Macros one day at a time
#6
Hibernate it instead of shutting down. I normally never shut down computer if I don't have to.

Don't know how reliable is this function. Maybe better to use a scheduled task with 'wake up' checked.
#7

What is the difference? I shut down my computer to cut back on power usage. Will hibernation have the same effect for the most part?
Taking on Quick Macros one day at a time
#8
When hibernated (or hybrid sleep on Vista), you can turn off power completely. The difference is that when you turn on, all running programs are restored like before hibernation.
#9

Oh okay, thanks for the explaination.


So I could program my computer to go into hibernation mode at night then auto turn on at 7:30 in the morning?
Taking on Quick Macros one day at a time
#10
How would it work to schedule a task to turn on a computer at a specific time and have it stay on; instead of like the example above where it turns on after a specific duration of time and then shuts off again after 2min or when the task it finished.

Basically I want my computer to hibernate during non-business hours and then turn on during business hours.

I.E...
Scheduled task a computer to hibernate at 6:00pm
Scheduled task a computer to wake up at 10:00am
Then the computer would stay on from 10:00am-6:00pm

I know something like this would work if I scheduled a task at 6:00p
Code:
Copy      Help
int hours seconds
hours =16
seconds=(hours*3600)
WakeUpAfter seconds 4

I would just prefer to have a Hibernate task and a Wake Up task...

Thanks,
Jimmy Vig
#11
Better use task scheduler.

function scheduled every day at 6 pm (probably "start when idle" should be checked in task properties):
shutdown 4

function scheduled every day at 10 am ("wake..." checked in task properties):
wait 0 M

The wait for mouse click command does not allow Windows to hibernate again if not using mouse or keyboard for several minutes. Or show message box.

------------------------------

SetWaitableTimer can wait for an absolute time too. If t is positive. Anyway, some calculations needed.
#12
I would like to make a program that triggers a timer to wait x minutes before actually going into hibernation...if a key or mouse are used within the wait period, then the timer would be reset. This way if I am on the computer after hours I don't have to worry about the whole thing going into hibernation while I am in the middle of something. I thought about using a dialog that would wait for cancel to be clicked to avoid going into hibernation, but then I'd always have to remember to hibernate manually when was done.

For example I would schedule a task to run an exe at 8:00pm. If the mouse and keyboard have not been used by 8:10 the computer will go into hibernation. If the mouse gets used at 8:05 then the computer would reset the timer for another 10minutes from the point when the mouse was no longer being used.

Could you please give an example of this?

Thanks,
Jimmy Vig
#13
Function ResumeWhenIdle
Code:
Copy      Help
;/
function idletime_s

;Waits until mouse and keyboard are not used for idletime_s seconds.


if(idletime_s<0 or idletime_s>2000000) end ES_BADARG
idletime_s*1000
opt waitmsg -1
LASTINPUTINFO in.cbSize=sizeof(in)
rep
,GetLastInputInfo &in
,int t=GetTickCount-in.dwTime
,if(t>idletime_s) break
,1
#14
Can the reverse be done?

Say do some function until the mouse is used or a button on the keyboard has been pressed.
#15
Thanks! Very nice, works perfectly!
#16
Quote:Can the reverse be done?
Let the macro repeatedly call GetLastInputInfo...
Macro
Code:
Copy      Help
out

int t0=GetTickCount
int i
for i 0 1000
,LASTINPUTINFO in.cbSize=sizeof(in); GetLastInputInfo &in
,if(in.dwTime-t0>0) break ;;mouse/keyboard used after the macro started
,
,out 1
,wait 1
,
#17
I do not think that could work better!
Thank You


Forum Jump:


Users browsing this thread: 1 Guest(s)