Jump to content

Choice of two windows


Recommended Posts

Hi everyone. I hope someone can help me.

I have used AutoIt v3 to create a script that will run an anti-spyware application scan. It start's up, It Sends, and acts on, the correct simulated keypresses to initiate the scan. The scan begins and completes as it should (thank you AutoIt). :)

Now my problem:

When the scan completes, a couple of windows can appear depending on whether the scan located any spyware or not. Usually/mostly the scans are clear and a little dialog pops up and says "All Clear" and the operator (me) has to click an OK button to close the dialog. This all works well in the AutoIt script, I use "WinWaitActive" to wait for that dialog to appear, then "Send" a simulated ENTER keystroke to close the dialog. Now........ if that dialog doesn't appear, i.e. if some spyware has been found, how do I get AutoIt to recognise that the "All Clear" dialog wont appear and stop waiting on it, so that I may get AutoIt to act on the delete spyware options?

Many thanks in advance.

Link to comment
Share on other sites

while 1
$window1=winwaitactive ("blah","")
$window2=winwaitactive ("blah2","")
if $window1=1 then
;do blaah
endif
if $window2=1 then
;do blah
endif
wend
Ahhhhhhh I see, <insert, slaps head smilie> . Thank you so much, backstabbed, I really appreciate your help. I've just started using AutoIt and couldn't figure it out for myself, that looks exactly like what I need.

Just one supplementary question, if I can impose on you a little more, please.

This script will be part of a larger script that I'm trying to create. The larger script runs a few other programs as well, the programs start, run and close, one after the other. I already have a "While 1 -- Wend" loop, so the one you have shown above will be Nested within the "While 1.....Wend" loop I already have. Will that be a problem do you think?

Link to comment
Share on other sites

  • Developers

The WinWaitActive() won't work to well when the second window becomes active ... You need to use WinExists() to test for multiple windows.

While 1
    If WinExists("window 1", "") Then
        ;do blaah
    EndIf
    If WinExists("window 2", "") Then
        ;do blaah
    EndIf
    Sleep(50)
WEnd
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The WinWaitActive() won't work to well when the second window becomes active ... You need to use WinExists() to test for multiple windows.

While 1
    If WinExists("window 1", "") Then
        ;do blaah
    EndIf
    If WinExists("window 2", "") Then
        ;do blaah
    EndIf
    Sleep(50)
WEnd
it was just a rough example -.- :)

tolle indicium

Link to comment
Share on other sites

The WinWaitActive() won't work to well when the second window becomes active ... You need to use WinExists() to test for multiple windows.

While 1
    If WinExists("window 1", "") Then
        ;do blaah
    EndIf
    If WinExists("window 2", "") Then
        ;do blaah
    EndIf
    Sleep(50)
WEnd
Thank you for your input, JdeB, I really do appreciate your help. I have used your code and it seems to be working okay at the moment. I hope to try backstabbed's idea as well when I have streamlined things a little more (need more spare time, lol). Thank you both sincerely for your help and time.
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...