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.

Dealing with Multiple Windows with Same Name
AND a More Advanced Analysis.WBT

Keywords: 	  advanced analysis.wbt  advanced control manager script multiple windows same name

Sometimes when using the Control Manager extnder it is found that there are more than one window with the same title, and that the DllHwnd function that is usually used to start a Control Manager transaction returns the incorrect window.

In this case we have to get the correct window handle for the desired window. First we have to get the applicable trash.txt files. The standard Window analysis script cannot do this, as it suffers from the same problem.

There is a more advanced Window Analysis script available. See below.

Assuming we have both Window Analysis scripts, we have to rummage through all the windows looking for the correct one.

This case here the top lines of the two trash.txt files read...

;TOP     #32770                     0     Visio Uninstall

and

TOP       Win32 Setup Shell Class   0      Visio Uninstall

In this example our job is to find a window with the #32770 class and Visio Uninstall as the title, and ignore the other one. The code below will do that. Once found, click the OK button in that window.

;Get the handle of a top level window.  Any one will do.
;In this case just grab the Winbatch window.
me=DllHwnd("")

;Now find the first window in the master list of all toplevel
;windows
workwindow=cWndInfo(me,4)

;Now work through the list, checking each window
while 1
   if workwindow==0
      Message("eeek","Window not found")
      break
   endif
   class=cWndInfo(workwindow,2)
   title=cWndInfo(workwindow,0)
   if class=="#32770" && title=="Visio Uninstall" then break
   workwindow=cWndInfo(workwindow,6)
endwhile

if workwindow!=0   ; push theOK button
    okButton1 = cWndByName (workwindow, "OK")
    cPostButton (okButton1)
endif

And the Advanced Window Analysis script that can help you sort out the windows is...


; This script creates a report on the windows visible at the time
; the report is run.  Run the script.  Choose a top-level
; window of interest, and it will show pertainent information
; that may be necessary to use the Control Manager extender.

; Note that Tabbed dialogs sometimes must be displayed before
; their controls are brought into existance.  So when using
; tabbed dialogs, tab to the correct dialog first.  The
; cWndInfo example shows how to move thru a tabbed dialog.

AddExtender("wwctl34I.dll")
AddExtender("WILX34I.DLL")
verx=cGetInfo(0)
fname="trash.txt"

a=""
moi=DllHwnd("")
topwindow=cWndInfo(moi,4)

nextwindow=topwindow
windowfound=@FALSE
while 1
   nextwindow=cWndInfo(nextwindow,6)
   if nextwindow==0 then break
   hexwnd=xBaseConvert(nextwindow,10,16)
   hexwnd=strfixleft(hexwnd,"0",8)
   winid=strcat("#WIN$ID#",hexwnd)
   wintt=cWndInfo(nextwindow,0)
   if wintt=="" then wintt=cWndInfo(nextwindow,2)
   if a=="" then a=strcat(winid,@tab,wintt)
   else a=strcat(a,"|",winid,@tab,wintt)
endwhile


b=AskItemList("Choose a Window",a,"|",@unsorted,@single)
b=ItemExtract(1,b,@tab)
hwnd=DllHwnd(b)
myfile=FileOpen(fname,"WRITE")

workwnd=hwnd
gosub gettextandclass
FileWrite(myfile,"Control Manager version %verx%")
FileWrite(myfile,"")
FileWrite(myfile,"")
FileWrite(myfile,"P   C   C   C   C")
FileWrite(myfile,"A   H   H   H   H")
FileWrite(myfile,"R   I   I   I   I")
FileWrite(myfile,"E   L   L   L   L")
FileWrite(myfile,"N   D   D   D   D")
FileWrite(myfile,strcat(strfix("T   2   3   4   5"," ",21),strfix("CLASS"," ",26),strfix("IDENT"," ",7),"TITLE"))

FileWrite(myfile,strfill("-",80))
FileWrite(myfile,strcat(strfix("TOP"," ",21),strfix(class," ",26),strfix(ident," ",7),text))

gosub ProcessChildren
FileClose(myfile)

Run("notepad.exe",fname)
exit

:ProcessChildren
nextchild=cWndInfo(workwnd,8)
ChildCount=0
if nextchild==0
   FileWrite(myfile,"    X                NONE")
else
   while nextchild
       ChildCount=ChildCount+1
       workwnd=nextchild
       gosub gettextandclass
       FileWrite(myfile," ")
       FileWrite(myfile,strcat("    ",strfix(ChildCount," ",17),strfix(class," ",26),strfix(ident," ",7),text))

       nextchild=cWndInfo(workwnd,6)
       gosub ProcessGrandchildren    ; note this destroys workwnd variable....
   endwhile
endif
return

:ProcessGrandchildren
grandchild=cWndInfo(workwnd,8)
GrandCount=0
if grandchild==0
   FileWrite(myfile,"        X            NONE")
else
   while grandchild
       GrandCount=GrandCount+1
       workwnd=grandchild
       gosub gettextandclass
       FileWrite(myfile,strcat("        ",strfix(GrandCount," ",13),strfix(class," ",26),strfix(ident," ",7),text))

       grandchild=cWndInfo(workwnd,6)
       gosub ProcessGreatGrandChildren
   endwhile
endif

return

:ProcessGreatGrandchildren
greatgrandchild=cWndInfo(workwnd,8)
greatGrandCount=0
if greatgrandchild==0
   FileWrite(myfile,"            X        NONE")
else
   while greatgrandchild
       greatGrandCount=greatGrandCount+1
       workwnd=greatgrandchild
       gosub gettextandclass
       FileWrite(myfile,strcat("            ",strfix(greatGrandCount," ",9),strfix(class," ",26),strfix(ident," ",7),text))

       greatgrandchild=cWndInfo(workwnd,6)
       gosub processlevel5
   endwhile
endif

return

:ProcessLevel5
L5child=cWndInfo(workwnd,8)
L5Count=0
if l5child==0
   FileWrite(myfile,"                X    NONE")
else
   while l5child
       l5count=L5Count+1
       workwnd=l5child
       gosub gettextandclass
       FileWrite(myfile,strcat("                ",strfix(L5Count," ",5),strfix(class," ",26),strfix(ident," ",7),text))

       l5child=cWndInfo(workwnd,6)
       gosub processlevel5
   endwhile
endif

return


:GETTEXTANDCLASS
text=cWndInfo(workwnd,0)
ident=cWndInfo(workwnd,1)
class=cWndInfo(workwnd,2)
return	 

Article ID:   W14521
Filename:   Dealing with Multiple Windows with Same Name.txt
File Created: 2017:07:28:12:58:25
Last Updated: 2001:03:02:13:35:28