krokkie Posted February 6, 2013 Share Posted February 6, 2013 I have a job that runs as a scheduled task, but because I have other apps runing on the server, it seems to stop at the login prompt. When you click on it, it then proceeds to run the job without problems. This is the part of the script that causes the issue: ;Sign In WinWaitActive("Dispatch Manager Sign In") Send($Pwd & "{Enter}") WinWaitActive("classname=TMessageForm") ;MsgBox(0,"Purge Disabled Records","TMessageForm") Send("{Enter}") ; ExitDM() I tried changing the second WinWaitActive to WinActive, but it still fails If I change bot to WinActive, it does not carry on with the job What command do I use to force the login prompt to always be active, no matter what other apps are running? Link to comment Share on other sites More sharing options...
Varian Posted February 6, 2013 Share Posted February 6, 2013 (edited) Have you tried a simple Activate/Wait util Active loop? Do WinActivate("classname=TMessageForm") Sleep(10) Until WinActive("classname=TMessageForm") Edited February 6, 2013 by Varian krokkie 1 Link to comment Share on other sites More sharing options...
Exit Posted February 7, 2013 Share Posted February 7, 2013 ;Sign In WinWaitActive("Dispatch Manager Sign In") Send($Pwd & "{Enter}") WinWaitActive("classname=TMessageForm") Second Winwaitactive has a systax error. Should read: WinWaitActive("[classname:TMessageForm]") krokkie 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
krokkie Posted February 7, 2013 Author Share Posted February 7, 2013 I will try both suggestions and report back. Thanks for your responses Link to comment Share on other sites More sharing options...
krokkie Posted February 7, 2013 Author Share Posted February 7, 2013 Your suggestions work fine, until I disconnect my RDP console session to the server. The schedule task starts but gets stuck on the login screen again Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2013 Share Posted February 7, 2013 It's probably because the windows aren't active if you're not connected/logged in to the server 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 GudeHow 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 More sharing options...
jdelaney Posted February 7, 2013 Share Posted February 7, 2013 (edited) Are you always logged in when this runs?If not, then you will not be able to make the window active.http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3FUsing WinExists will work (loop until it does), and then wait for the WinGetState to include is visible, and is enabled...then use controlsend instead of send Edited February 7, 2013 by jdelaney krokkie 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
krokkie Posted February 7, 2013 Author Share Posted February 7, 2013 What is the best way to get this script to run whilst the server is disconnected? Link to comment Share on other sites More sharing options...
krokkie Posted February 7, 2013 Author Share Posted February 7, 2013 Cheers, I will try that Link to comment Share on other sites More sharing options...
krokkie Posted February 7, 2013 Author Share Posted February 7, 2013 Can you give me an idea as how to script this? Link to comment Share on other sites More sharing options...
jdelaney Posted February 8, 2013 Share Posted February 8, 2013 I'd suggest doing an action, and writing the results of that action to a log file, so you know exactly what's going on. So, if the function returns an HWnd, add a step directly after that function to validate that it was a success...use If IsHWnd() Then Only proceed to the next action if the prior was a success Output all steps to a log That way, you can ask constructive things, like, why is 'this' function failing? instead of broad this isn't working statements IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
krokkie Posted February 8, 2013 Author Share Posted February 8, 2013 Thanks jdelaney I have no prior scripting experience. This script was done a few years ago by my predecessor. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now