Question about UseWindow

Advanced programming using WinTask scripting language

Question about UseWindow

Postby gwiesenekker on Sun Jan 04, 2015 8:40 pm

I am trying to automate an application. The windows have titles like "ABC" and "AB" and I am using #UseExact = 1.
A dialog box is shown with the title "A", but UseWindow seems to activate the window with the title "ABC". How can I select the window the title "A"?

Gijsbert
gwiesenekker
 
Posts: 4
Joined: Sun Jan 04, 2015 8:22 pm

Re: Question about UseWindow

Postby TechSupport on Mon Jan 05, 2015 8:50 am

Hello,

What is your UseWindow line? Can you share the exact syntax that you have for UseWindow for the A only, and for the UseWindow for the AB only?

Regards.
Tech Support
TechSupport
 
Posts: 805
Joined: Thu Nov 16, 2006 9:58 am

Re: Question about UseWindow

Postby gwiesenekker on Fri Jan 16, 2015 10:56 pm

It seems to depend on the order in which the windows have been opened. Create three text-files ‘A.txt’, ‘AB.txt’ and ‘ABC.txt’. Start Notepad, Open ‘AB.txt’; Start Notepad, Open ‘ABC.txt’; Start Notepad, Open ‘A.txt’. Now run the script:

#UseExact=1
UseWindow("NOTEPAD.EXE|Edit|A",1)
SendKeys("Does it type<Enter>")

The text will be entered into the window with the title 'AB.txt'.

Regards,
Gijsbert
gwiesenekker
 
Posts: 4
Joined: Sun Jan 04, 2015 8:22 pm

Re: Question about UseWindow

Postby TechSupport on Mon Jan 19, 2015 3:01 pm

Hi,
Here is how window name truncation works when #UseExact=1

UseWindow("NOTEPAD.EXE|Edit|A|1",1) triggers for any window with Class Edit, window title starting with A, so A, AB, AC, AAA,… will trigger but not B or BC
UseWindow("NOTEPAD.EXE|Edit|AB|1",1) triggers for any window with Class Edit, window title starting with AB, so AB, ABC, ABCC will trigger, but not AC, AA, …
UseWindow("NOTEPAD.EXE|Edit|ABC|1",1) triggers for any window Edit class, title starting with ABC, so ABCA, ABCD will trigger, but not ABB, ABD, …

For the notepad specific example, it’s easy to make the SendKeys sending the keys to the correct window, because there are 3 instances of notepad, so if you use:
UseWindow("NOTEPAD.EXE|Edit|A.txt - Notepad|1",3)
The UseWindow will trigger any window name starting with A but only if it’s the 3rd instance.

If in your real case, the instance number is the same too, then you will need to use UseWindowHandle to trigger the window specified by its handle.

Best regards.
WinTask Tech Support
TechSupport
 
Posts: 805
Joined: Thu Nov 16, 2006 9:58 am


Return to Scripts programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron