Jump to content

check which window pops up


Recommended Posts

Hi guys,

Been using autoit-3 for 2 days now. Can some one please help me with the following problem?

I have a program running and I am using code to run a procedure from the menu items. The procedure will either display an completed OK window or an error window ( both requiring an OK button to be clicked).

I have written the following code to do just the error condition, now I want to add the if...else, but I can not get it working. this is working

Opt("WinTitleMatchMode", 4)
                        WinWait("DriveRight Software 2.6.2","")
                        WinMenuSelectItem("DriveRight Software 2.6.2","","&DriveRight","&Download DriveRight")
                        WinWait("Communication Error","DriveRight is not responding. ")
                        ControlClick("Communication Error","DriveRight is not responding. ","Button1")

this is not working

WinWait("DriveRight Software 2.6.2","")
                        WinMenuSelectItem("DriveRight Software 2.6.2","","&DriveRight","&Download DriveRight")
                        if WinActive("Communication Error","DriveRight is not responding. ") then
                            WinActivate("Communication Error","DriveRight is not responding. ")
                        ;WinWait("Communication Error","DriveRight is not responding. ")
                            msgbox(4096,"","sleeping",5)
                            ControlClick("Communication Error","DriveRight is not responding. ","Button1")
                        EndIf

thanks in advance

Link to comment
Share on other sites

  • Moderators

Try this:

Local $MainTitle = "DriveRight Software 2.6.2"
Local $ChildTitle = "Communication Error"
Local $ChildText = "DriveRight is not responding. "
Opt('WinSearchChildren', 1)
WinWait($MainTitle)
WinMenuSelectItem($MainTitle,"","&DriveRight","&Download DriveRight")
WinWait($ChildTitle, $ChildText, 5) ; Putting this here, maybe you're window doesn't exist before it gets to the if statement.
If WinExists($ChildTitle,$ChildText) Then
    WinActivate($ChildTitle,$ChildText)
    MsgBox(4096,"","sleeping",5)
    ControlClick($ChildTitle,$ChildText,"Button1")
Else
    MsgBox(64, 'Info', 'The Window: ' & $ChildTitle & ' does not exists'
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks. Your code works.

I put my code back in and changed a few things to see why my code did not work.

I found that if I changed the "If WinActive" to "If WinExists" it works.

I don't understand why, as in my testing I will always get the error window and it is active when it pops up.

One of lifes little mysteries. :">

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