Jump to content

Waiting for desktop to stabilise...


Recommended Posts

Hello members,

I need to install a scientific application that is packaged with WISE, across about 100 workstations in a Windows Active Directory environment.   As a sysadmin I'm used to using scripts, etc to automate such processes but this particular software needed baby sitting to apply a registration key.   So my usual vbScript, batch, PowerShell etc did not address the "baby sitting" task.

I have now used AutoIT pretty successfully so far to automate the installation and apply the registration keys.  So far so good!

What I would now like to do is launch this script (compiled to an exe) from a group policy.   My first thought was to launch it from a computer startup policy (i.e. when the workstation boots up, it announces itself to Active Directory and AD runs policies to it.   The AutoIT compiled script was one of those.)   This way, with suitable testing to see if the installation had already taken place, all my users had to do was turn on their workstations and wait a bit longer than usual that first time, while the installer ran.   Nirvana!

I had the (scientific programme) installer set to "silently" install the programme using its /s switch and fired off by a Run command within my AutoIT script.   Much of the process actually ran, but it would never apply the registration keystrokes.   I worked out that this was because AutoIT was dependent on a "canvas" where it would expect to see "windows" appearing :-)

Okay, so what about running it from a user logon policy - when any user logs on, this would be one of the policies applied and there would be a desktop (a "canvas") on which the windows would appear, and AutoIT could detect them and proceed with poking out the registration keystrokes.   Well, it worked but intermittently.   Some workstations completed fine, others "hung" with the rego screen on display but obviously not recognised by my AutoIT script.   I suspect this is due to these (hung) workstation's desktops not having settled down before the (scientific software) registration-step window appeared.

I could manually complete the rego screen tasks and the software got installed okay, but the AutoIT compiled script never went to completion presumably because it was still looking for what it thought of as a "missing" window.

I coded in several WinWaits and Sleeps and WinActivates in an effort to let it be more stable but I think there might be a way to detect "stability" in the desktop, or maybe you experienced folks have a better method to propose for cases.

My ideal of course would be to do it at computer boot time, but the lack of a "canvas" would seem to be a killer :-)   The only way I can see that the WISE installer can communicate is via a windowed environment (no, the application has not been packaged for command-line installation!   If it had, I would probably have remained an AutoIT spectator :-))

Worst comes to worst I could build in a huge time delay which should guarantee desktop stability, but that seems a kludge to me.

Kind regards,
Denis

P.S.

Hmmm... I wonder if I used the "timeout" parameter in WinWait and a loop to keep on waiting for success??   Maybe that would be more successful in a dynamic desktop environment?   I.e....

       Do

          Sleep (1000)

      Until (WinWait("Window title",, 1) <> 0)

My logic being that it would keep trying every second to detect the sought-after window, with a 1-second timeout (2 seconds overall loop timing.)   Is that worth a try?

Link to comment
Share on other sites

Welcome as an active AutoIt forum user!

It would be quite helpful if you could post the relevant part of your script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hope this does not multi-post; I replied to this thread this morning, but it has not appeared in the discussion as yet...
 
 
 
Thank you, "water" 
 
As requested...
 
<quote>
; We now have things in place to launch the installer in silent mode.
; Run the installer
;
        Run($strInstaller)
 
; Some time later the first screen to appear is the registration screen (asking for rego key)
;
        WinWait($strRegoScreenTitle)
; Add some sleep time (seems to help with reliability of detecting the rego window)
        Sleep(4000)
        WinActivate($strRegoScreenTitle)
 
; Now send keystrokes to insert the rego key...
; When the above code "works", the sending rego keys code which follows, always works.
<unquote>
 
The problem is that (unless the desktop is stabilised???) the WinWait($strRegoScreenTitle) is not always detected by the AutoIT script.    The rego screen appears on the desktop but is somehow "ignored", is the best way I can describe it.
 
When I say "the desktop has stabilised", if I run this script "manually" from the user's desktop, it *always* runs to completion.   But if it is fired off as part of the user logon process, its preceding parts (setting up some installer pre-requisites which do not require window interaction) always execute.
 
Kind regards and thanks for any insights,
Denis
Link to comment
Share on other sites

Maybe the real title of the window and $strRegoScreenTitle don't match. What is your setting for

AutoItSetOption("WinTitleMatchMode",n)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks, water...

I did not set anything explicitly so it would be running the default "match from the start"   I was very particular to note the precise wording, including case, of the title in the rego window and replicate it in my $strRegoScreenTitle variable.   In any event i expect that since it works "once the desktop has stabilised" as I like to think of it - i.e. fired off manually by the user - that it should be matching okay.

Tomorrow (it being Sunday here in Australia) I will attempt to implement my wait-for-stability scheme I mentioned in my original post.   Of course I will experiment with other window title matching options just in case there is something there I have overlooked.

Ahhh... just thought of something!   What if the rego window does not have focus when the rest of the desktop is being painted at user logon time?   In other words, it exists but is not active!?   Perhaps the use of the WinExists function could help me here, in case it is hidden or otherwise defocussed!   So maybe...

; Wait patiently for the rego screen...

Do

    Sleep(500)

Until WinExists($strRegoScreenTitle)

; When it exists, activate it (give it focus)...
WinActivate($strRegoScreenTitle)
; Now send keystrokes to insert the rego key...
 
I suppose the big trick with all Windows work, especially when the desktop painting is in a state of flux, is to force and maintain focus on the task (window) at hand.   As a human operator, no problem; we can re-focus if required.   But automation is a different matter.
 
Kind regards and I appreciate any counter arguments to the above.   Always learning :-)
Denis
Link to comment
Share on other sites

To make your script more reliable (and remove the need to set focus to the window) use ControlSend.

Use the AutoIt Window Info Tool to get the ControlId.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hello water,

Success!!!  :)

I had success with the Do...Until method and found that I had to implement it in two places, for the WinExists as well as the WinActivate.   So my code looks like this now...

; Run the installer
;
        Run($strInstaller)
 
; Some time later the first screen to appear is the registration screen (asking for rego key)
;
        Do
            Sleep(500)
        Until WinExists($strRegoScreenTitle)

; Now forcibly activate the rego window, in case other on-desktop activity is trying to steal focus
;
        Do
            Sleep(500)
        Until WinActivate($strRegoScreenTitle)

; Send the rego key codes...

I will look into the Window Info tool as it sounds promising, so thanks for that lead.

Kind regards,
Denis

Link to comment
Share on other sites

Looks like a huge step to solve your problem ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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