Sign in to follow this  
Followers 0
krokkie

WinWaitActive?

12 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have you tried a simple Activate/Wait util Active loop?

Do
  WinActivate("classname=TMessageForm")
  Sleep(10)
Until WinActive("classname=TMessageForm")
Edited by Varian
1 person likes this

Share this post


Link to post
Share on other sites

;Sign In

WinWaitActive("Dispatch Manager Sign In")

Send($Pwd & "{Enter}")

WinWaitActive("classname=TMessageForm")

Second Winwaitactive has a systax error. Should read:

WinWaitActive("[classname:TMessageForm]")
1 person likes this

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

I will try both suggestions and report back.

Thanks for your responses

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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.3F

Using 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 by jdelaney
1 person likes this

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.

Share this post


Link to post
Share on other sites

What is the best way to get this script to run whilst the server is disconnected?

Share this post


Link to post
Share on other sites

Cheers, I will try that

Share this post


Link to post
Share on other sites

Can you give me an idea as how to script this?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thanks jdelaney

I have no prior scripting experience.

This script was done a few years ago by my predecessor.

Share this post


Link to post
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
Sign in to follow this  
Followers 0