Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
I wrote a little tool to paddle up and down the control-hierarchy like you do with directories normally. The handle, Name, ID, and Class of every control is shown.
Note that the handle is only of temporary use, it will be altered with the next start of the tested application.
When the special branch you examine stops, this will be shown by a sign (||).
Additionally you can test (uses cPostMessage) the control by a numeric command (uses cPostMessage). Try:
16 :This deletes the button 18 : This closes the application 49 : This changes the font 77 : This shows the help 123: Gives a popup "Help" 245: PUSHES the buttonBe careful with 8, 10, 11, 108, 109, 110. They make the button unable to receive any more commands. Also, you should consider that sending unexpected commands to controls can cause your programs to hang. Try it at your own risk :-)
I do not too much about this (API?) commands. Maybe one of the experts can add some hints.
Perhaps this is useful for anybody to understand the control structure of Windows applications, as it was to me.
Best wishes from Germany,
Hannes
;This script allows to dig into the hierarchy of windows, subwindows, controls, etc. ;The user can send a specific order to any of the controls. Here is what I found out with the ;example of notepadīs "Open"-dialogbox. If you test one of the buttons, you can, for ;example, send a ;16 : This deletes the button ;18 : This closes the application ;49 : This changes the font ;77 : This shows the help ;123 : Gives a popup "Help" ;245 : PUSHES the button ; ;Be careful with 8, 10, 11, 108, 109, 110. They make the button unable to receive any more ;commands. Also, you should consider that sending unexpected commands to controls can cause your ;programs to hang. Try it at your own risk :-) ;Best wishes from Germany, Hannes Frischat, frischat@dynamic.fkp.uni-hannover.de AddExtender("wwctl34I.dll") parents=WinItemize() DoneList = "" H = 1 ;layer of the hierarchy appname = "" WHILE appname == "" appname=AskItemList("Choose an application (layer %H%)",parents,@tab,@sorted,@single) ENDWHILE H = H + 1 ;handle of parent window phwnd = DLLhwnd(appname) EndHandleList = phwnd ;optionally, once you found the interesting ;control, you can monitor its position in ;the hierarchy with that. psize=strlen(appname) ;this is a very useful trick I took from xxx=strreplace(appname," ","?") ;an answer by Mike Murphy (mmurphy@shl.com) Message("Length of applicationīs name) = %psize%",xxx) While 1 GOSUB GetTheChilds GOSUB ShowTheChilds ; and ask GOSUB TestIt GOSUB DecideNext ENDWHILE :GetTheChilds ;uses H,phwnd,EndHandleList,appname ;Message("EndHandleList", EndHandlelist) ;for Debugging TempHandlelist = "" ;this lists the handles of the childs firstchildhandle = cWndInfo(phwnd, 8) IF firstchildhandle != 0 childhandle = firstchildhandle n = 1 WHILE childhandle != 0 TempHandlelist = ItemInsert(childhandle, n, TempHandlelist,@tab) ;Message("", TempHandlelist) ;for Debugging childhandle = cWndInfo(childhandle, 6) n = n+1 ENDWHILE ENDIF ;Message("TempHandleList", TempHandleList) ;for Debugging drop(firstchildhandle,n,childhandle) RETURN :ShowTheChilds ;uses TempHandleList ShowList = "" m = ItemCount(TempHandlelist, @tab) ;creation of ShowList For n = 1 to m hwnd = ItemExtract(n, TempHandleList, @tab) Name = cWndInfo(hwnd, 0) Name=strreplace(Name," ","?") ID = cWndInfo(hwnd, 1) Class= cWndInfo(hwnd, 2) NextChild = cWndInfo(hwnd, 8) IF NextChild == 0 NextChar = " ||" ELSE NextChar = "" ENDIF IF ItemLocate(hwnd, DoneList, @tab) != 0 DoneChar = " T" ELSE DoneChar = "" ENDIF Item = StrCat(hwnd, " NAME:", Name, " ID:", ID, " CLASS:", Class, NextChar, DoneChar) ShowList = ItemInsert(Item, n, ShowList, @tab) NEXT IF H > 2 THEN ShowList = strcat("[..]", @tab, ShowList) Item = "" WHILE Item == "" Item = AskItemList("Layer %H% of %appname%", ShowList,@tab,@unsorted,@single) ENDWHILE drop(hwnd,Name,ID,Class,Nextchild,NextChar,DoneChar,ShowList) RETURN :TestIt ;uses Item, DoneList, IF Item != "[..]" goahead = @FALSE While goahead != @TRUE q = AskYesNo("","You chose %@CRLF%%Item%%@CRLF%%@CRLF%Test it with a numeric command?") THwnd = ItemExtract(1, Item, " ") IF q == @YES l = Askline("", "Number to test", "245") IF IsInt(l) == @FALSE Message("", "You cheat! Wasnīt a number!") ELSE GOSUB PostItbreak DoneList = ItemInsert(THwnd, -1, DoneList, @tab) ENDIF ELSE goahead = @TRUE ENDIF ENDWHILE ENDIF drop(goahead) RETURN :DecideNext ;uses Item,EndHandleList,Phwnd,H IF Item == "[..]" EndHandleList=ItemRemove(H, EndHandleList, @tab) ;Message("EndHandleList", EndHandleList) H = H - 1 Phwnd = cWndInfo(Phwnd, 3) ELSE Phwnd = ItemExtract(1, Item, " ") EndHandleList = ItemInsert(Phwnd, -1, EndHandleList, @tab) ;Message("EndHandleList", EndHandleList) H = H + 1 ENDIF ;Message(H, EndHandleList) ; for debugging drop(Item) RETURN :PostItBreak ; uses l, Item WinActivate(appname) Pause("Test of %Item%", "Do test with %l%?") ;optional i = cPostMessage(THwnd, l,0,0) Pause("Test of %Item%","PostMessage %l%%@CRLF%Answer %i%") drop(i) RETURN
Article ID: W12520
Filename: Control the Controls.txt
File Created: 2001:03:02:14:39:22
Last Updated: 2001:03:02:14:39:22