Jump to content
Sign in to follow this  
cmaney

Newbie question about active window

Recommended Posts

cmaney

I've written a pretty simple script for logging into a Windows program, entering data into a search field, and then printing a report and then iterating to the next search item/print job, etc.  It all works... most of the time.

The problem appears to be because sometimes one of the dialog windows opens up and says "Loading data..." for a couple of seconds before the menus become available.  The window is *active*, but the buttons and such are not clickable until the data is there.  (I'm using WinWait to make sure the window shows up.)  Oh, and the "Loading data..." cue is not in a recognizable "field" that I can just reference, but rather is overlaid on the app just below the title bar.

I've put in some Sleep(time) commands to make it work, but it has not been reliable enough because the times vary based on system load, etc.  I'm sure this has come up before, but I haven't yet found anything here in the forums.  So... what is the best way to fix this? 

Thanks for your help!

Share this post


Link to post
Share on other sites
JLogan3o13

What information do you get on this dialog window if you use the AutoIt Window Info Tool?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
cmaney

Quick update: after formatting my thoughts to post this question, it suddenly came to me that I could check to see if a button was enabled or not using the ControlCommand isEnabled stuff.  That solves one of the two places where this happens!

The other (much smaller but related) issue is the base screen when the application first starts up, and it doesn't have any buttons that I can check.  This is not a dialog window, but rather the whole application!  I'm trying to grab a screen shot, but it goes pretty quickly.  I've been unable to get the Window Info Tool to show anything in that area other than the basic stuff like this:

>>>> Window <<<<
Title: Intergy EHR
Class: HwndWrapper[intergyEHR.exe;;86af992e-dcae-4442-af56-17501931d5f1]
Position: 0, 10
Size: 1024, 721
Style: 0x16CF0000
ExStyle: 0x00040100
Handle: 0x00020172
 
>>>> Control <<<<
Class:
Instance:
ClassnameNN:
Name:
Advanced (Class):
ID:
Text:
Position:
Size:
ControlClick Coords:
Style:
ExStyle:
Handle:
 
What, specifically, should I be looking for?
 
Note: the main application *does* do the "Loading..." thing, too... that is not just in the dialog windows.  I suspect the application is using html to create most elements on the screen, but that is just a feeling, and I cannot edit it to see.
Edited by cmaney

Share this post


Link to post
Share on other sites
cmaney

Ok, I've found some more.  When the application is *done* loading, there is a button that isn't really a button labelled "New Task".  Is there a way to check to see if it exists?  It doesn't exist before the "loading..." goes away.

Here's the Windows Info tool output for that section of the page:

>>>> Control <<<<
Class: WindowsForms10.Window.8.app.0.3f81d7f_r12_ad1
Instance: 11
ClassnameNN: WindowsForms10.Window.8.app.0.3f81d7f_r12_ad111
Name: panelTasks
Advanced (Class): [NAME:panelTasks]
ID: 197284
Text:
Position: 716, 115
Size: 423, 20
ControlClick Coords: 179, 16
Style: 0x56000000
ExStyle: 0x00010000
Handle: 0x000302A4
 
>>>> Mouse <<<<
Position: 895, 141
Cursor ID: 0
Color: 0xD4D0C8
 
>>>> StatusBar <<<<
 
>>>> ToolsBar <<<<
 
>>>> Visible Text <<<<
New Task
Show Detail
Summary
Tasks    

Share this post


Link to post
Share on other sites
j0kky

You can try this to wait the control appearance:

While Not ControlGetHandle("Intergy EHR", "", "[ID:197284]")
    Sleep(100)
WEnd
Edited by j0kky

Share this post


Link to post
Share on other sites
cmaney

J0kky:  That looks very promising, but I have a "which came first" problem if I understand that correctly...

Since the ID is generated fresh every time the control is created, how can I reference it to see if it exists?  (ie, the 197284 value changes every time that screen starts up.)

Is there a way to do something similar with the NAME:panelTasks?

Share this post


Link to post
Share on other sites
tonycst

Search window for text, not the Classname control if it changes everytime.

If button is in the same location, you can just press it with coordinates of the screen of the application window its self if it moves.

Share this post


Link to post
Share on other sites
tonycst

Looks like under Tools/SciTE Config/General 2/Uncheck Inline Errors

does the job.

I had no clue scite had settings :)

Share this post


Link to post
Share on other sites
cmaney

There's always someone that says 'rtfm', isn't there?  I already *read* the controls help, and I even tried using what was there before I posted.  Congratulations on being entirely non-helpful, j0kky.

ControlGetHandle says it has to use the control ID [iD:123456], not the Name [NAME:panelTasks], but I tried it anyway with no luck.  

I'm working on an alternative solution now to skip that whole issue.  I'll post again if I manage to figure it out.

And thanks, tonycst... I'll explore the page searching line of thought.

And unrelated, but I did find out that the majority of the application is rendered in html, but when you click on the html buttons, some of the pop-ups are actually programs (with real buttons!) and not other html pages.

Share this post


Link to post
Share on other sites
j0kky

"Parameter controlID: The control to interact with. See Controls." (from ControlGetHandle)

"A special description can be used as the controlID parameter used in most of the Control...() functions. This description can be used to identify a control by the following properties:

•ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screen readers for the blind and Microsoft tools/APIs may allow you to get this Control ID

•TEXT - The text on a control, for example "&Next" on a button

•CLASS - The internal control classname such as "Edit" or "Button"

•CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

•NAME - The internal .NET Framework WinForms name (if available)

•REGEXPCLASS - Control classname using a regular expression

•X Y W H - The position and size of a control.

•INSTANCE - The 1-based instance when all given properties match.

One or more properties are used in the controlID parameter of a control command in the format:

[PROPERTY1:Value1; PROPERTY2:Value2]" (from Controls help page)

I give you the way to wait for the control and the page that tells you how to identifying the control (but obviously you didn't read carefully). Am I entirely unhelpful? Good luck with your script.

Share this post


Link to post
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
Sign in to follow this  

×