Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to get control names and contents?


  • Please log in to reply
12 replies to this topic
charliemopps
  • Members
  • 117 posts
  • Last active: Nov 30 2010 09:50 PM
  • Joined: 09 Feb 2006
I am trying to upgrade one of my scripts. Basically it fills out forms for me that have combinations of List boxes, combo boxes, and buttons. Right now I am just throwing keystrokes at the form... like {TAB 3}sitesname{TAB 4}{Enter}{Tab 14}Low level{ENTER}
etc...

just sending keyboard commands has its obvious disadvantages, so I want to start sending directly to the controls. But I don't know what their names are. I've tried using Window spy, but I can never get it to work.

I wrote this basic script that gets a list of the control names... but I don't know what they relate to in the program. I need to have my script also output what's IN the field at the time... then I can figure out "Oh, that's the city field!" etc...

WinGet, ActiveControlList, ControlList, A
Loop, Parse, ActiveControlList, `n
{
FileAppend,
(
Control #%a_index% is "%A_LoopField%". 

), C:\Controls.txt 

}

Output looks like:
Control #1 is "MDIClient1".
Control #2 is "Afx:400000:b:0:6:4042f1".
Control #3 is "#327701".
Control #4 is "Edit1".
Control #5 is "Button1".
Control #6 is "Button2".
Control #7 is "Button3".
Control #8 is "Button4".
Control #9 is "Button5".
Control #10 is "Button6".
Control #11 is "Button7".
Control #12 is "Button8".
Control #13 is "Button9".
Control #14 is "Button10".
Control #15 is "Button11".
Control #16 is "Button12".
Control #17 is "Button13".
Control #18 is "Button14".
Control #19 is "Button15".
Control #20 is "Button16".
Control #21 is "Button17".
Control #22 is "Button18".
Control #23 is "Button19".
Control #24 is "Static1".
Control #25 is "AfxControlBar421".
Control #26 is "AfxControlBar422".
Control #27 is "AfxControlBar423".
Control #28 is "AfxControlBar424".
Control #29 is "#327702".
Control #30 is "Static2".
Control #31 is "Edit2".
Control #32 is "AfxMDIFrame421".
Control #33 is "#327703".
Control #34 is "SysListView321".
Control #35 is "SysHeader321".
Control #36 is "AfxFrameOrView421".
Control #37 is "RichEdit20A1".
Control #38 is "Afx:400000:b:0:6:4042f2".
Control #39 is "#327704".
Control #40 is "Edit3".
Control #41 is "Button20".
Control #42 is "Button21".
Control #43 is "Button22".
Control #44 is "Button23".
Control #45 is "Button24".
Control #46 is "Button25".
Control #47 is "Button26".
Control #48 is "Button27".
Control #49 is "Button28".
Control #50 is "Button29".
Control #51 is "Button30".
Control #52 is "Button31".
Control #53 is "Button32".
Control #54 is "Button33".
Control #55 is "Button34".
Control #56 is "Button35".
Control #57 is "Button36".
Control #58 is "Button37".
Control #59 is "Button38".
Control #60 is "Static3".
Control #61 is "AfxControlBar425".
Control #62 is "AfxControlBar426".
Control #63 is "AfxControlBar427".
Control #64 is "AfxControlBar428".
Control #65 is "#327705".
Control #66 is "Static4".
Control #67 is "Edit4".
Control #68 is "AfxMDIFrame422".
Control #69 is "#327706".
Control #70 is "SysListView322".
Control #71 is "SysHeader322".
Control #72 is "AfxFrameOrView422".
Control #73 is "Afx:400000:b:10011:6:4042f1".
Control #74 is "#327707".
Control #75 is "Edit5".
Control #76 is "Button39".
Control #77 is "Button40".
Control #78 is "Button41".
Control #79 is "Button42".
Control #80 is "Button43".
Control #81 is "Button44".
Control #82 is "Button45".
Control #83 is "Button46".
Control #84 is "Button47".
Control #85 is "Button48".
Control #86 is "Button49".
Control #87 is "Button50".
Control #88 is "Button51".
Control #89 is "Button52".
Control #90 is "Button53".
Control #91 is "Button54".
Control #92 is "Button55".
Control #93 is "Button56".
Control #94 is "Button57".
Control #95 is "Static5".
Control #96 is "AfxControlBar429".
Control #97 is "AfxControlBar4210".
Control #98 is "AfxControlBar4211".
Control #99 is "AfxControlBar4212".
Control #100 is "#327708".
Control #101 is "Static6".
Control #102 is "Edit6".
Control #103 is "AfxMDIFrame423".
Control #104 is "#327709".
Control #105 is "SysListView323".
Control #106 is "SysHeader323".
Control #107 is "AfxFrameOrView423".
Control #108 is "AfxFrameOrView424".
Control #109 is "Shell Embedding1".
Control #110 is "Shell DocObject View1".
Control #111 is "Internet Explorer_Server1".
Control #112 is "Afx:400000:b:0:6:4042f3".
Control #113 is "#3277010".
Control #114 is "Edit7".
Control #115 is "Button58".
Control #116 is "Button59".
Control #117 is "Button60".
Control #118 is "Button61".
Control #119 is "Button62".
Control #120 is "Button63".
Control #121 is "Button64".
Control #122 is "Button65".
Control #123 is "Button66".
Control #124 is "Button67".
Control #125 is "Button68".
Control #126 is "Button69".
Control #127 is "Button70".
Control #128 is "Button71".
Control #129 is "Button72".
Control #130 is "Button73".
Control #131 is "Button74".
Control #132 is "Button75".
Control #133 is "Button76".
Control #134 is "Static7".
Control #135 is "AfxControlBar4213".
Control #136 is "AfxControlBar4214".
Control #137 is "AfxControlBar4215".
Control #138 is "AfxControlBar4216".
Control #139 is "#3277011".
Control #140 is "Static8".
Control #141 is "Edit8".
Control #142 is "AfxMDIFrame424".
Control #143 is "#3277012".
Control #144 is "SysListView324".
Control #145 is "SysHeader324".
Control #146 is "AfxFrameOrView425".
Control #147 is "msctls_statusbar321".
Control #148 is "AfxControlBar4217".
Control #149 is "ToolbarWindow321".
Control #150 is "ToolbarWindow322".
Control #151 is "ToolbarWindow323".
Control #152 is "ToolbarWindow324".
Control #153 is "ToolbarWindow325".
Control #154 is "ComboBox1".
Control #155 is "ToolbarWindow326".
Control #156 is "AfxControlBar4218".
Control #157 is "AfxControlBar4219".
Control #158 is "AfxControlBar4220".


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
untested
WinGet, ActiveControlList, ControlList, A

FileAppend, Ctrl #`tClasNN`tData`n, C:\Controls.txt
Loop, Parse, ActiveControlList, `n
{
ControlGetText, theText, %A_LoopField%
FileAppend, %a_index%`t%A_LoopField%`t%theText%`n, C:\Controls.txt

}


charliemopps
  • Members
  • 117 posts
  • Last active: Nov 30 2010 09:50 PM
  • Joined: 09 Feb 2006
That worked... but I'm realizing now that my problem is that it is only pulling data from the control bar/file menu....

The program I'm pulling this from has "Sub-windows" inside it. Each form is its own window inside the form. How do I get controls from inside THOSE windows?

Here's what the program looks like. I am only getting the controls that are in the sorrounding window in the titel bar... And the controls in the inner window I get nothing from.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Here's what the program looks like. I am only getting the controls that are in the sorrounding window in the titel bar... And the controls in the inner window I get nothing from.


Download and run this file: <!-- m -->http://dl.dropbox.co... ... rolSPY.ahk<!-- m -->
When you inner window has focus, Press CTRL+WIN+ALT+F12
I would like to see the results.

:?:

charliemopps
  • Members
  • 117 posts
  • Last active: Nov 30 2010 09:50 PM
  • Joined: 09 Feb 2006
Here you go... and btw... none of this makes sense with what I'm seeing on my screen. I again think that it is pulling from the main outer window

Remedy User - NTRS-Trouble (Modify) [Class]
---------------------------------------------------------------------------------------------------
Sl   c_Hwnd       ClassNN                                  Control Text (40 Characters only)       
---------------------------------------------------------------------------------------------------

1  . 0x4050c      MDIClient1                               
2  . 0x200654     Afx:400000:b:0:6:2f04c11                 NTRS-Trouble (Modify)
3  . 0x1c061a     #327701                                  
4  . 0xc068a      Edit1                                    
5  . 0x17066e     Button1                                  Fields
6  . 0x15062c     Button2                                  (
7  . 0xe0612      Button3                                  )
8  . 0xc0626      Button4                                  "
9  . 0x17062e     Button5                                  +
10 . 0x1106a8     Button6                                  -
11 . 0x2a0606     Button7                                  *
12 . 0x1a0658     Button8                                  /
13 . 0x7f06a6     Button9                                  %
14 . 0xe0642      Button10                                 =
15 . 0xd0622      Button11                                 !=
16 . 0x100660     Button12                                 <
17 . 0x320674     Button13                                 >
18 . 0x2a0670     Button14                                 <=
19 . 0xf0610      Button15                                 >=
20 . 0xf063e      Button16                                 LIKE
21 . 0xf0666      Button17                                 AND
22 . 0x1a065c     Button18                                 OR
23 . 0x9068c      Button19                                 NOT
24 . 0x100644     Static1                                  &Search Criteria:
25 . 0x260636     AfxControlBar421                         
26 . 0xb0686      AfxControlBar422                         
27 . 0x1406a0     AfxControlBar423                         
28 . 0xb0616      AfxControlBar424                         
29 . 0xb069c      #327702                                  PromptBar
30 . 0x1b0650     Static2                                  
31 . 0xe0630      Edit2                                    The Responsible Party Name is the specif
32 . 0x220684     AfxMDIFrame421                           
33 . 0xb0638      #327703                                  ResultsView
34 . 0x170694     SysListView321                           List1
35 . 0x1a065a     SysHeader321                             
36 . 0x2307f2     AfxFrameOrView421                        FormView
37 . 0x9d06f6     RichEdit20A1                             NM OPS
38 . 0x180620     Afx:400000:b:0:6:2f04c12                 Alert List
39 . 0x12066a     #327704                                  
40 . 0x170690     Edit3                                    
41 . 0x17069e     Button20                                 Fields
42 . 0x2d0676     Button21                                 (
43 . 0xa067a      Button22                                 )
44 . 0x9067c      Button23                                 "
45 . 0x1c066c     Button24                                 +
46 . 0xe0634      Button25                                 -
47 . 0x90688      Button26                                 *
48 . 0x2006a2     Button27                                 /
49 . 0x2e0672     Button28                                 %
50 . 0xa0692      Button29                                 =
51 . 0xc0698      Button30                                 !=
52 . 0xa0682      Button31                                 <
53 . 0x140614     Button32                                 >
54 . 0x19067e     Button33                                 <=
55 . 0x1506a4     Button34                                 >=
56 . 0xd0648      Button35                                 LIKE
57 . 0xc0656      Button36                                 AND
58 . 0xd064a      Button37                                 OR
59 . 0x1c065e     Button38                                 NOT
60 . 0x230678     Static3                                  &Search Criteria:
61 . 0xd0640      AfxControlBar425                         
62 . 0x130600     AfxControlBar426                         
63 . 0xc06e6      AfxControlBar427                         
64 . 0x2106f4     AfxControlBar428                         
65 . 0x1c0750     #327705                                  PromptBar
66 . 0x14071c     Static4                                  
67 . 0x150776     Edit4                                    
68 . 0x160768     AfxMDIFrame422                           
69 . 0x150790     #327706                                  ResultsView
70 . 0x220736     SysListView322                           List1
71 . 0x2207d2     SysHeader322                             
72 . 0x240704     AfxFrameOrView422                        FormView
73 . 0x140548     Afx:400000:b:0:6:2f04c13                 NTRS-Control Panel (New)
74 . 0x1204a8     #327707                                  
75 . 0x1e0522     Edit5                                    
76 . 0x60488      Button39                                 Fields
77 . 0x25048a     Button40                                 (
78 . 0x704a0      Button41                                 )
79 . 0xc051e      Button42                                 "
80 . 0xd052c      Button43                                 +
81 . 0x180536     Button44                                 -
82 . 0x804fa      Button45                                 *
83 . 0xa04ac      Button46                                 /
84 . 0x504ee      Button47                                 %
85 . 0x504f0      Button48                                 =
86 . 0x50502      Button49                                 !=
87 . 0xb0510      Button50                                 <
88 . 0x70482      Button51                                 >
89 . 0x504d8      Button52                                 <=
90 . 0x804aa      Button53                                 >=
91 . 0x504d6      Button54                                 LIKE
92 . 0x704c8      Button55                                 AND
93 . 0x904ae      Button56                                 OR
94 . 0x704ca      Button57                                 NOT
95 . 0x9049a      Static5                                  &Search Criteria:
96 . 0x804da      AfxControlBar429                         
97 . 0x604e0      AfxControlBar4210                        
98 . 0x604ec      AfxControlBar4211                        
99 . 0x1b04b4     AfxControlBar4212                        
100. 0x704cc      #327708                                  PromptBar
101. 0xa04bc      Static6                                  
102. 0x804f8      Edit6                                    
103. 0x13051c     AfxMDIFrame423                           
104. 0x7050a      #327709                                  ResultsView
105. 0x904b0      SysListView323                           List1
106. 0xf04c6      SysHeader323                             
107. 0x110530     AfxFrameOrView423                        FormView
108. 0x750544     Afx:400000:b:10011:6:2f04c11             Home Page (Search)
109. 0x60484      #3277010                                 
110. 0xb0500      Edit7                                    
111. 0xf0554      Button58                                 Fields
112. 0x240546     Button59                                 (
113. 0x60486      Button60                                 )
114. 0x17050e     Button61                                 "
115. 0x904e6      Button62                                 +
116. 0x904e4      Button63                                 -
117. 0x150552     Button64                                 *
118. 0x904f2      Button65                                 /
119. 0x704b6      Button66                                 %
120. 0xb054e      Button67                                 =
121. 0xc0516      Button68                                 !=
122. 0x70508      Button69                                 <
123. 0x704fe      Button70                                 >
124. 0x704fc      Button71                                 <=
125. 0x704e2      Button72                                 >=
126. 0x704f4      Button73                                 LIKE
127. 0x704e8      Button74                                 AND
128. 0x804b2      Button75                                 OR
129. 0xb054c      Button76                                 NOT
130. 0xc053c      Static7                                  &Search Criteria:
131. 0xd0512      AfxControlBar4213                        
132. 0xf0532      AfxControlBar4214                        
133. 0x1304ba     AfxControlBar4215                        
134. 0x160542     AfxControlBar4216                        
135. 0x1d04c2     #3277011                                 PromptBar
136. 0x704f6      Static8                                  
137. 0xc051a      Edit8                                    
138. 0x80506      AfxMDIFrame424                           
139. 0xe04c4      #3277012                                 ResultsView
140. 0x804ea      SysListView324                           List1
141. 0x804d4      SysHeader324                             
142. 0xc053a      AfxFrameOrView424                        FormView
143. 0x804dc      AfxFrameOrView425                        ViewSymbolWnd
144. 0xc0538      Shell Embedding1                         
145. 0xa04a6      Shell DocObject View1                    
146. 0x120550     Internet Explorer_Server1                
147. 0x70480      msctls_statusbar321                      Ready
148. 0x60498      AfxControlBar4217                        
149. 0x130668     ToolbarWindow321                         
150. 0xb0680      ToolbarWindow322                         
151. 0x11053e     ToolbarWindow323                         
152. 0x160526     ToolbarWindow324                         
153. 0x3048c      ToolbarWindow325                         Macro
154. 0x3048e      ComboBox1                                
155. 0x80494      ToolbarWindow326                         Standard
156. 0x5049c      AfxControlBar4218                        
157. 0x404a2      AfxControlBar4219                        
158. 0x4049e      AfxControlBar4220                        
---------------------------------------------------------------------------------------------------
* Control Spy * By Goyyah


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
Skan, you need to update the fileappend at the end to not be Goyyah anymore =-) (why did you switch anyway)

charliemopps, it looks like this program uses MDI, which can be troublesome. I think there have been other topics about MDI in the forum.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
I too do not understand. :roll: You will have to wait for PhiLho. :)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Skan, you need to update the fileappend at the end to not be Goyyah anymore =-) (why did you switch anyway)


I am just using the file posted by Goyyah. Updating the older files would be very tedious. :D

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
I'm sure you could write a script for that 8)

Loop, c:\*.ahk, 1  ;recursive
{
  FileRead, script, %A_LoopFileFullPath%
  StringReplace, newscript, script, Goyyah, Skan, All
  If (script != newscript)
  {
    FileRecycle, %A_LoopFileFullPath%
    FileAppend, %newscript%, %A_LoopFileFullPath%
  }

} 


SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I'm sure you could write a script for that 8)


:lol: .. Nice one. BTW, for about 80% of my code lies scattered though out the forum for which I do not have a backup. :roll:

  • Guests
  • Last active:
  • Joined: --

Here's what the program looks like. I am only getting the controls that are in the sorrounding window in the titel bar... And the controls in the inner window I get nothing from.


Download and run this file: <!-- m -->http://dl.dropbox.co... ... rolSPY.ahk<!-- m -->
When you inner window has focus, Press CTRL+WIN+ALT+F12
I would like to see the results.

:?:


OMG ! this is what I want !!! control text and all !

working on a fully untended mass uninstaller :) let me know if you know of such a script !

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
very nice skan
Never lose.
WIN or LEARN.

dytanaka
  • Members
  • 4 posts
  • Last active: Jun 27 2014 09:40 PM
  • Joined: 21 Nov 2013

Hi,

I have a similar issue.  I am cutting and pasting from excel in to forms and it works, but it has issues on the browser side.  Here is a sample the HTML of the php table and buttons.  It there any way I can sent the data directly to the controls?  I have tried Autoit3 and Goyyah’s Control.Spy.Report but it does not return anything.  Does anyone have any ideas, I would really appreciate any help.

 

RES AUTO MAINTENANCE - Google Chrome [Class:Chrome_WidgetWin_1]

Control.Spy.Report

---------------------------------------------------------------------------------------------------

Sl   c_Hwnd       ClassNN                                  Control Text (40 Characters only)      

---------------------------------------------------------------------------------------------------

 

1  . 0x1902d4     Chrome_WidgetWin_01                      RES AUTO MAINTENANCE

2  . 0xb02d0      Chrome_RenderWidgetHostHWND1            

---------------------------------------------------------------------------------------------------

* Control Spy * By Goyyah

****************Sample HTML *******************

<table><tbody><tr>

<th align="left">LOCN</th>

<td><select name="locn"><option value="ABE">ABE</option>

<option value="ABI">ABI</option>

<option value="ABQ">ABQ</option>

<option value="ABY">ABY</option>

<option value="ACT">ACT</option>

<option value="" selected=""></option>

  </select>

</td>

</tr>

<tr>

<th align="left">PROD</th>

<td><input type="text" name="prod" maxlength="12" size="10" value="" onchange="if (prod.value =='') prod.value=' '; else upperStr(prod);">

</td>

</tr>

<tr>

<th align="left">DESC</th>

<td colspan="3"><input type="text" name="descr" maxlength="52" size="50" value="" onchange="if (descr.value =='') descr.value=' '; else upperStr(descr);">

</td>

</tr>

<tr>

<th align="left">VENDOR</th>

<td><input type="text" name="vendor" maxlength="12" size="10" value="" onchange="if (vendor.value =='') vendor.value=' '; else upperStr(vendor);">

</td>

 

<input type="submit" name="reqflag" value="DONE" class="button">

<input type="submit" name="reqtype" value="CANCEL" class="button">

<input type="submit" name="menu" value="AUTO LIST" class="button" onclick="main.action=&quot;rsautolist.php&quot;;">