Jump to content

WinExists not appearing to match correctly


 Share

Recommended Posts

Hiya,

I am trying to automate the clicking of a dialogue box that sometimes can appear.  This is to automate the logging onto a text based OS.

The code for the dialogue box is this:

sleep(4000)

   If WinExists("[CLASS:Static; INSTANCE:1]") Then
      ConsoleWrite("found window")
      Sleep(3000) ; couple of seconds to collect thoughts
      Send("{ENTER}")
      Exit
   Else
      ConsoleWrite("carry on")
   EndIf

But even if the dialogue box doesn't show up, it's sending enter, which is messing up the following sequences.  I have tried to use ControlClick and for some reason it just doesn't do anything.  I used WindowInfo to find the dialogue box information and that is the following:

>>>> Window <<<<
Title:  Reflection Workspace
Class:  #32770
Position:   401, 422
Size:   484, 189
Style:  0x94C801C5
ExStyle:    0x00010101
Handle: 0x00190924

>>>> Control <<<<
Class:  Static
Instance:   1
ClassnameNN:    Static1
Name:   
Advanced (Class):   [CLASS:Static; INSTANCE:1]
ID: 65535
Text:   Unable to locate Theme file: ProgramFilesFolder\Attachmate\Reflection\Private\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.
Position:   12, 26
Size:   431, 62
ControlClick Coords:    239, 28
Style:  0x50022080
ExStyle:    0x00000004
Handle: 0x0017095A

>>>> Mouse <<<<
Position:   655, 501
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Unable to locate Theme file: ProgramFilesFolder\Attachmate\Reflection\Private\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.


>>>> Hidden Text <<<<

And the WindowInfo of the main program if the dialogue box doesn't show

>>>> Window <<<<
Title:  Reflection Workspace - [filename.rd3x]
Class:  WindowsForms10.Window.8.app.0.73673b_r16_ad1
Position:   -8, -8
Size:   1296, 1000
Style:  0x17CF0000
ExStyle:    0x00050100
Handle: 0x005F0CE6

>>>> Control <<<<
Class:  WindowsForms10.Window.8.app.0.73673b_r16_ad1
Instance:   1
ClassnameNN:    WindowsForms10.Window.8.app.0.73673b_r16_ad11
Name:   tabStrip
Advanced (Class):   [NAME:tabStrip]
ID: 2556064
Text:   
Position:   0, 153
Size:   1280, 26
ControlClick Coords:    866, 13
Style:  0x56010000
ExStyle:    0x00000000
Handle: 0x002700A0

>>>> Mouse <<<<
Position:   866, 158
Cursor ID:  0
Color:  0xE5E9ED

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
bottomDockSite
topDockSite
rightDockSite
leftDockSite
DCStatusBar
ribbonControl1
&Host
&Clipboard
&Transfer
&Productivity
&Screen History
&Macros
DocViewContainerMdiClient
TN3270DEV.rd3x
smartuxbg


>>>> Hidden Text <<<<
Standard

I am currently using WinTitleMatchMode 1 to get exact title matches,  but I have tried using 2 and 3 and am getting similar results.  If the dialogue box shows up it will always bring it into focus hence why I thought simply sending enter would work.  Could I perhaps do something such as if the main window is not in focus?  This should be simple and I've used if statements for WinExists loads of times so I am unsure why this isn't working...

 

I've tried matching the window title, but unfortunately the main program title is the same, and I get the same result when I match with just CLASS #32770.

Link to comment
Share on other sites

The title of the window is Reflection Workspace and its class name is #32770
The button is classNN is [CLASS:Static; INSTANCE:1]

So you should use something like this :

If WinExists("[TITLE:Reflection Workspace; CLASS=#32770]") Then
    ControlClick( "[TITLE:Reflection Workspace; CLASS=#32770]", "", "[CLASS:Static; INSTANCE:1]")
EndIf

 

 

Link to comment
Share on other sites

Unfortunately this isn't doing the trick.  The "Contents" of the popup is thus:

>>>> Window <<<<
Title:  Reflection Workspace
Class:  #32770
Position:   705, 273
Size:   486, 189
Style:  0x94C801C5
ExStyle:    0x00010101
Handle: 0x00130EA8

>>>> Control <<<<
Class:  Static
Instance:   1
ClassnameNN:    Static1
Name:   
Advanced (Class):   [CLASS:Static; INSTANCE:1]
ID: 65535
Text:   Unable to locate Theme file: C:\Users\Public\Documents\Attachmate\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.
Position:   12, 26
Size:   431, 62
ControlClick Coords:    46, 28
Style:  0x50022080
ExStyle:    0x00000004
Handle: 0x00061038

>>>> Mouse <<<<
Position:   766, 352
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Unable to locate Theme file: C:\Users\Public\Documents\Attachmate\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.


>>>> Hidden Text <<<<

The button of the window is this:

>>>> Window <<<<
Title:  Reflection Workspace
Class:  #32770
Position:   705, 273
Size:   486, 189
Style:  0x94C801C5
ExStyle:    0x00010101
Handle: 0x00130EA8

>>>> Control <<<<
Class:  Button
Instance:   1
ClassnameNN:    Button1
Name:   
Advanced (Class):   [CLASS:Button; INSTANCE:1]
ID: 2
Text:   OK
Position:   383, 124
Size:   88, 26
ControlClick Coords:    58, 16
Style:  0x50030000
ExStyle:    0x00000004
Handle: 0x00100E1A

>>>> Mouse <<<<
Position:   1149, 438
Cursor ID:  0
Color:  0xD8D8D8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Unable to locate Theme file: C:\Users\Public\Documents\Attachmate\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.


>>>> Hidden Text <<<<

The outside of the button (the border etc) is this:

>>>> Window <<<<
Title:  Reflection Workspace
Class:  #32770
Position:   705, 273
Size:   486, 189
Style:  0x94C801C5
ExStyle:    0x00010101
Handle: 0x00130EA8

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

>>>> Mouse <<<<
Position:   909, 289
Cursor ID:  0
Color:  0x121517

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Unable to locate Theme file: C:\Users\Public\Documents\Attachmate\Default\Users\Themes\Reflection2007.3270.themex.
The default theme will be used.


>>>> Hidden Text <<<<

To debug I've just put a little consolewrite in your IF statement

If WinExists("[TITLE:Reflection Workspace; CLASS=#32770]") Then
   ConsoleWrite("Found popup window")
    ControlClick( "[TITLE:Reflection Workspace; CLASS=#32770]", "", "[CLASS:Static; INSTANCE:1]")
EndIf

but it's not writing it to the console, even though the window is appearing.  I am stuck on how to get AutoIt to find this window :(

Link to comment
Share on other sites

Try with this :

If WinExists("Reflection Workspace") Then
   ConsoleWrite("Found popup window")
    ControlClick( "Reflection Workspace", "", "[CLASS:Button; INSTANCE:1]")
EndIf

 

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