Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: probe windows
; Larry Clanton ; netmeister@atti.com ; This program recursively traverses the selected window logging all child and ; sibling objects. ; ; This program can be modified to look for a particular Object Name of Class Name. ; The variable hwnd will be set to the handle value of the object being sought ; upon return from the GOSUB to GETWINDOWINFO. ; ; This has been tested up to 8 levels. It should work on as many levels as you encounter ; due to the recursive calls. ;ENVIRONSET("DEBUGING","ON") ;DEBUGING=ENVIRONMENT("DEBUGING") ;IF "%DEBUGING%"== "ON" THEN DebugTrace(@ON,"c:\tracefile.txt") ;ENVIRONSET("EXTENDER","wwctl34i.dll") ;EXTENDER=ENVIRONMENT("EXTENDER") AddExtender("wwctl34i.dll") ENVIRONSET("OBJECTLOG","YES") OBJECTLOG=ENVIRONMENT("OBJECTLOG") if FileExist("c:\tracefile.txt")==@TRUE then FileDelete("c:\tracefile.txt") if FileExist("c:\childlist.txt")==@TRUE then FileDelete("c:\childlist.txt") GOSUB VARINIT :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; To observe how to retrieve an object handle comment out GOTO HOPOVER below and run this ; script on an NT 4 box. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: GOTO HOPOVER INST=0 FOUND=0 Atarget="&Replication" hwnd=0 Run("rundll32.exe", "shell32.dll,Control_RunDLL srvmgr.cpl") hChildWnd%INST%=DllHwnd("Server") GOSUB GETWINDOWINFO if FOUND==1 then Display(3, "","Handle Found for Child Object &Replication!") cPostButton(hwnd) GOSUB VARINIT INST=0 FOUND=0 Atarget="Cancel" hChildWnd%INST%=DllHwnd("Directory Replication") hwnd=0 FOUND=0 GOSUB GETWINDOWINFO cPostButton(hwnd) GOSUB VARINIT hwnd=0 FOUND=0 Atarget="Cancel" hChildWnd%INST%=DllHwnd("Server") hParnetWnd=hChildWnd%INST% GOSUB GETWINDOWINFO cPostButton(hwnd) if FileExist("c:\childlist.txt")==@TRUE then Run("notepad.exe","c:\childlist.txt") exit else Display(3,"", "Handle not found!") endif exit :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :HOPOVER INST=0 ;Must be set to 0 before looking for object FOUND=0 ;Must be set to 0 before looking for object Atarget="NO_OP" ;Name of object or Class Name to be found hwnd=0 ;Handle of object found a=WinItemize() b=AskItemList("Choose a Window",a,@tab,@unsorted,@single) hChildWnd%INST%=DllHwnd(b) GOSUB GETWINDOWINFO if FileExist("c:\childlist.txt")==@TRUE then Run("notepad.exe","c:\childlist.txt") exit :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :WRITEDAT if OBJECTLOG<>"YES" then return GOSUB TESTFORPARENT myfile=FileOpen("c:\childlist.txt","APPEND") if ctr == 0 then FileWrite(myfile,strfix("-","-",70)) FileWrite(myfile,strcat(strfix(" "," ",2),strfix("ID"," ",8),strfix("Handle"," ",10),strfix("Class"," ",25),strfix("Parent"," ",10),strfix("Object Name"," ",12))) FileWrite(myfile,strfix("-","-",70)) FileWrite(myfile,strcat(strfix(" "," ",BASEVALUE),strfix(Aident," ",8),strfix(hwnd," ",10),strfix(Aclass," ",25),strfix("< -X- >"," ",10),strfix(Atext," ",24))) ctr=1 else FileWrite(myfile,strcat(strfix(" "," ",BASEVALUE),strfix(Aident," ",8),strfix(hwnd," ",10),strfix(Aclass," ",25),strfix(Aparent," ",10),Atext)) endif FileClose(myfile) GOSUB SAVEREC RCOUNT=RCOUNT+1 return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :GETTEXTIDCLASS Atext=cWndInfo(hwnd,0) Aident=cWndInfo(hwnd,1) Aclass=cWndInfo(hwnd,2) Aparent=cWndInfo(hwnd,3) if Atarget==Atext then FOUND=1 if Atarget==Aclass then FOUND=1 return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :GETWINDOWINFO hwnd=hChildWnd%INST% CTR=0 GOSUB GETTEXTIDCLASS GOSUB WRITEDAT if FOUND==1 then return :GETHANDLETEST hChildWnd%INST%=cWndInfo(hChildWnd%INST%,8) if hChildWnd%INST% == 0 then return else hwnd=hChildWnd%INST% GOSUB GETTEXTIDCLASS GOSUB WRITEDAT if FOUND==1 then return endif hCurrentParentWnd=hChildWnd%INST% INST=INST+1 hChildWnd%INST%=hCurrentParentWnd GOSUB GETHANDLETEST if FOUND==1 then return INST=INST-1 hSiblingWnd%INST%=cWndInfo(hChildWnd%INST%,6) while hSiblingWnd%INST% <>0 hwnd=hSiblingWnd%INST% GOSUB GETTEXTIDCLASS GOSUB WRITEDAT if FOUND==1 then return hCurrentSibling=hSiblingWnd%INST% INST=INST+1 hChildWnd%INST%=hCurrentSibling GOSUB GETHANDLETEST if FOUND==1 then return INST=INST-1 hSiblingWnd%INST%=cWndInfo(hSiblingWnd%INST%,6) endwhile return return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :SAVEREC PREVTEXT=Atext PREVIDENT=Aident PREVCLASS=Aclass PREVPARENT=Aparent PREVHWND=hwnd return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :TESTFORPARENT HWND%RCOUNT%=hwnd BASEVALUE%RCOUNT%=BASEVALUE for tctr=0 to RCOUNT if HWND%tctr%==Aparent then BASEVALUE=BASEVALUE%tctr%+3 BASEVALUE%RCOUNT%=BASEVALUE break endif next return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :VARINIT BASEVALUE=2 NEWCHILD="NO" PREVTEXT="NODATA" PREVIDENT="NODATA" PREVCLASS="NODATA" PREVPARENT="NODATA" PREVHWND=0 RCOUNT=0 return ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Article ID: W15353
File Created: 2002:09:05:13:51:26
Last Updated: 2002:09:05:13:51:26