Jump to content

Help with a loop


Recommended Posts

Hello everyone, new to autoit. I have a window that shares a common name with several others. I need to search it for a specific string, and click "ok". So far, I have this:

Global $s_title_of_popup = "WINDOW NAME"
Global $s_msgbox_class = "#32770"
 

While 1
    WinWait("[Title:" & $s_title_of_popup ["$sText"] & "Class:" & $s_msgbox_class & "]")
    ControlClick("[Title:" & $s_title_of_popup ["$sText"] & "Class:" & $s_msgbox_class & "]", "", "Button1")
 WEnd

This works well at replying with OK to any window by that name. I need to add a third global variable, which is the content of text from the window. I tried this:

Global $s_title_of_popup = "WINDOW NAME"
Global $s_msgbox_class = "#32770"
Global $sText = WinGetText ("WINDOW NAME" ["SPECIFIC STRING"])

While 1
    WinWait("[Title:" & $s_title_of_popup ["$sText"] & "Class:" & $s_msgbox_class & "]")
    ControlClick("[Title:" & $s_title_of_popup ["$sText"] & "Class:" & $s_msgbox_class & "]", "", "Button1")
 WEnd

Unfortunately this does not run (at all), it errors out line 3. Error: Subscript used on non-accesible variable.

 

I am sure I've done something obvious, but I've tried a few things and can't get it right, so I'll post here for help. What I need to do is:

run a .exe in the background (most likely as a service)
have that .exe constantky looking for a popup window
if the popup window contains a specific string, click ok

 

 

 

Link to comment
Share on other sites

I wouldn't use variables like you do to get access to a window.  It is very hard to read, and it is useless, since you will refer to them only once, at the first Win* () function.  Because after that statement, you should use the window handle provided by the Win* () function.

Local $hWnd = WinWait ("[TITLE: something; CLASS:#32770]")
ControlClick ($hWnd, "", "Button1")

Don't you think it is clearer ?

Link to comment
Share on other sites

Hey all, ty. Nine, that's very clean, thank you. I just need to add a second condition, in addition to title. The condition needs to be matching a string in the body of the popup.

 

Therefore:

While 1
    Local $hWnd = WinWait (Title: something; need to find specific string also Class:#32770]")
    ControlClick (hWnd, "", Button1")

WEnd

 

Appreciate all the help!

Link to comment
Share on other sites

So far, no luck. This is my current code:

While 1
    Local $hWnd = WinWait ("[TITLE: titleofwindow , textofwindow; CLASS:#32770]")
    ControlClick ($hWnd, "", "Button1")
WEnd

 

Probably not doing something abundantly obvious again. It does execute without errors, but it's not accomplishing the objective.

Link to comment
Share on other sites

Every time I try to structure as dictated by the paremeters of winwait, it highlights the first [, as a syntax error.

WinWait ( "title" [, "text" [, timeout = 0]] )

Should this be:

Winwait ("windowtitle" [, "windowtext") ?

 

Link to comment
Share on other sites

Link to comment
Share on other sites

I cannot get this to work, I just get unable to parse line. The syntax of autoit is....frustrating.

 

While 1
    Local $hWnd = WinWait ("WINDOWTITLE" "WINDOWTEXT" CLASS:#32770)
ControlClick ($hWnd, "", "Button1")
 WEnd

 

The unable to parse line error is focused on the #

Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks, tried it, does nothing. The popup remains un-acknowledged.

 

While 1
    Local $hWnd = WinWait ("[TITLE: windowname; CLASS:#32770]", "specific string")
    ControlClick ($hWnd, "", "Button1")
 WEnd

Link to comment
Share on other sites

Link to comment
Share on other sites

>>>> Window <<<<
Title:    DeltaV Logon
Class:    #32770
Position:    298, 264
Size:    429, 200
Style:    0x94C801C5
ExStyle:    0x00010101
Handle:    0x001A0738

>>>> Control <<<<
Class:    
Instance:    
ClassnameNN:    
Name:    
Advanced (Class):    
ID:    
Text:    
Position:    
Size:    
ControlClick Coords:    
Style:    
ExStyle:    
Handle:    

>>>> Mouse <<<<
Position:    409, 292
Cursor ID:    0
Color:    0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
PROVOX Logon failure!
Reason: Failed logon attempt, the user name does not exist
Please use the PROVOX Logon utility to try again.
DeltaV Logon was successful.


>>>> Hidden Text <<<<
 

Link to comment
Share on other sites

I am using the window name "DeltaV Logon" and the text "PROVOX Logon failure!"

There are other windows with the title "DeltaV Logon" that I do not want to do anything to, hence my desire to also use specific text from the message.

Link to comment
Share on other sites

post button au3info in here, put a msgbox (0,"",$hWnd) after WinWait so we can see if it gets the window or not, post screen capture of popup in here

Edited by Nine
Link to comment
Share on other sites

I pasted the info from au3info, from the summary tab. Could you clarify what you mean?

 

Also, can't get it to parse. 

While 1
    Local $hWnd = WinWait msgbox(0,"",$hWnd) ;("[TITLE: DeltaV Logon; CLASS:#32770]", "PROVOX Logon failure"))
   ControlClick($hWnd, "", "Button1")
 WEnd

 

I am terrible with autoit syntax.

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