WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Control Manager
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Differentiate between Two Child Windows with Same Name

Keywords: 	  differentiate child windows

Question:

How can I differentiate two windows with exactly the same name, the same ID and the same class?

I have used the windows analysis script to run on my program.

Answer:

Here is some code that might help.
Run( 'WordPad.exe', '' )
Run( 'WordPad.exe', '' )

LookingFor = 'WordPad'
list = WinItemNameId( )
listcount = ItemCount(list,'|')

ID1 = 'NOT FOUND'
ID2 = 'NOT FOUND'
IDX = 1
For xx=1 To listcount By 2
   thisname = ItemExtract(xx, list, '|' )
   thisid = ItemExtract( xx+1, list, '|' )
   If StrIndex( thisname, LookingFor, 1, @FWDSCAN )
      ID%IDX% = thisid
      IDX = 2
   EndIf
Next

Message('Parent Window IDs', ID1:@CRLF: ID2)

;Now we have the ID's of the two windows. Now we have to tell which is which.
ID1List=WinItemChild(ID1)
If ItemCount( ID1List, @TAB ) == 0
   Pause( '[Window 1] : ':ID1, 'No Child Windows Found' )
Else
   AskItemlist( '[Window 1] : ':ID1, ID1List, @TAB, @SORTED, @SINGLE )
EndIf
ID2List=WinItemChild(ID2)
If ItemCount( ID2List, @TAB ) == 0
   Pause( '[Window 2] : ': ID2, 'No Child Windows Found' )
Else
   AskItemlist( '[Window 2] : ':ID2, ID2List, @TAB, @SORTED, @SINGLE )
EndIf

;Clean up
WinClose( ID1 )
WinClose( ID2 )
Exit

Article ID:   W12510
Filename:   How to Differentiate 2 Child Windows with Same Name.txt
File Created: 2017:07:28:13:58:26
Last Updated: 2012:11:09:13:45:21