How to close window using GetWindowText

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Provalian
Newbie
Posts: 7
Joined: Mon Jan 23, 2006 3:41 pm
Location: Roanoke VA

How to close window using GetWindowText

Post by Provalian » Mon Jan 23, 2006 4:14 pm

I'm wanting to close a window once the program has finished and window is displaying the word "Finished". Using View System Window I've identified the handle - class name and object text as follows:
Window Name-263896 - App032 "ProVal Interface"
Area of Window-198376 - Static "Finished"
It can take hours for this to run so I guess I need the script to loop until the window displays finished. I do not know how to proceed from here to bring Finished in to my script in order to close the window. Your help for this beginner would be appreciated.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Jan 23, 2006 4:37 pm

Check out Help for WaitWindowOpen

RunProgram>Drive\Path\program.exe
WaitWindowOpen>Finished*
Do other stuff or stop as desired.
Last edited by Bob Hansen on Mon Jan 23, 2006 8:12 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

IanSmith
Junior Coder
Posts: 24
Joined: Tue Jul 12, 2005 2:31 pm

Post by IanSmith » Mon Jan 23, 2006 5:04 pm

Bob, is Finished the name of the window, or the text he's looking for? If it's just the text wwo won't help (although I defer to your greater knowledge...)

Things to think about; is the cursor an hourglass when the app is running? If so, you could use the WaitCursorChanged (wcc) command to test for this.

If the ProVal Interface window is the main window running, and the text appears on it, you can use the GetWindowText command to dump the text into a variable and then use Position to grep for it.

Pseudo code might look like this:

GWT>ProVal Interface,windowtext
pos>Finished,%windowtext%,1,finishedresult
if>%finishedresult%>0
the program has ended
endif

Take care, Ian

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Jan 23, 2006 8:14 pm

Finished is the name of the Window, not the text.
I missed your mention that it displayed the text "Finished".

But you can still use the correct name of the window if it is not name Finished.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Provalian
Newbie
Posts: 7
Joined: Mon Jan 23, 2006 3:41 pm
Location: Roanoke VA

How to close window with GetWindowText

Post by Provalian » Mon Jan 23, 2006 8:46 pm

Thanx Ian. Your suggestion is exactly what I was looking for. The word Finished is not the window name but is text present within the window once the program has completed.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Jan 25, 2006 2:32 pm

...you might also try using GetControlText.

GCT>WindowName,Static,X,TextFound

where X is the instance of the Static text within the WindowName.

I like using gct in this case...seems more exact....What if Finished appears somewhere else on the screen? Like an error message saying, "Unable to display Finished".....

SkunkWorks

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts