Jump to content

Possible to scrape all controls on a form?


Recommended Posts

I'm trying to use autoit to generate a list of all editboxes on a windows form. like a simple vbasic form with 5 edit boxes.

I'd like to scrape the form for all "children" and make a list of the controls. I was trying to use _WinAPI_GetWindow and if I use the $GW_CHILD option, I can get the handle of the first editbox control on that page. But How do I get the rest?

Link to comment
Share on other sites

Look at _WinAPI_EnumWindows, _WinAPI_EnumWindowsChild - I think it will help you to start.

Also search forum I think this was discussed here already.

Here are some links for you

http://www.autoitscript.com/forum/index.ph...st&p=595834

Func _GetClassName($hWnd)
  Local $ret = DllCall("User32.dll", "int", "GetClassName", "hwnd", $hWnd, "str","", "int", 4096)
  Return $ret[2]
EndFunc
Edited by Zedna
Link to comment
Share on other sites

That link returns an error

Code from corrupted/deleted post

; get rid of $ctrl & $n from $ctrlIDs and you could StringSplit() IDs into an array.

Send("#r")
WinWait("Run")
$ctrlIDs = ""
$buffer = @LF & WinGetClassList("Run")
While StringLen($buffer) > 1
    $ctrl = StringTrimLeft(StringLeft($buffer,StringInStr($buffer,@LF,0,2)-1),1)
    $n = 1
    While StringInStr($buffer,@LF & $ctrl & @LF)
       $hwnd = ControlGetHandle("Run","",$ctrl & $n)
       $ID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
       $ctrlIDs &= $ctrl & $n & "=" & $ID[0] & ","
       $buffer = StringReplace($buffer,@LF & $ctrl & @LF,@LF,1)
       $n+=1
    WEnd
WEnd
$ctrlIDs = StringTrimRight($ctrlIDs,1)
MsgBox(4096,"",$ctrlIDs)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...