Jump to content

Can't run scheduled script when computer is in sleep mode


wmrazek
 Share

Recommended Posts

Hi!

This is my first post. I just discovered autoit and it's great!

I have a sheduled task that runs a autoit script. When the computer is in run mode (never sleep or hibernate) it works fine. Now I want to save power (and save our world) by setting the computer to sleep mode and run the sheduled task. This is not working. The script starts a program, uses mouse movements, keystrokes and opens windows. Task scheduler history tells that the task is started and then times out (after 1 hour). 

The script starts a program AmiBroker, see code below. It goes wrong at the "If WinActive("AmiBroker")" statement, that tells if the window is active or not. And it is not active. So it goes wrong here and I'm stuck here ... ;0) 

; Start Amibroker
Local $iPID = Run("C:My Program FilesAmiBrokerBroker.exe")
Sleep(10000)
If WinExists("AmiBroker") Then
   _FileWriteLog($hFile, "Amibroker has started")
EndIf
WinActivate("AmiBroker")
If WinActive("AmiBroker") Then
   _FileWriteLog($hFile, "Amibroker window is active")
Else
   _FileWriteLog($hFile, "Amibroker window is not active")
EndIf
 

 

 

I'm using w-7. In Task Scheduler I have checked the option "Wake the computer to run this task"  (Properties for the task -> tab Conditions). 

I also have an other scheduled task that not uses autoit and this task works fine in sleep mode. This task runs a bat-file that calls a small C# application made in MS Visual Studio. 

I'm logged in at the computer when it goes to sleep.

Can someone help me with some hints or tips? 

Best Regards,

Wolfgang 

Link to comment
Share on other sites

https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

As explained there, you can't do what you're trying to do if the screen is locked. Windows will never be active when Windows is locked, so you can't use Send/WinActive/Winactivate/etc.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...