Sign in to follow this  
Followers 0
j8kin

How to get control information?

8 posts in this topic

I have a problem with identification of control in my Auto-It scrip.

I have some dialog and have a lot of controls in it.

Also I have ID (it means that I have a handler) of Control which i need to access.

But I don't understand how to get information about control such as Class/Type.

I search thought WinAPI functions and Auto-It help but failed.

Could anybody tell me is it possible to get Class/Type information of control.

Thanks

Eugene...

Share this post


Link to post
Share on other sites



Use the AutoIt Window Info to see the class of a control

Share this post


Link to post
Share on other sites

Actually I want to get this information in script automatically.

I want to do something like:

Select

Case GetControlInfo($hControl) = "Radio"

....

Case GetControlInfo($hControl) = "ListBox"

etc

Share this post


Link to post
Share on other sites

Actually I want to get this information in script automatically.

I want to do something like:

Select

Case GetControlInfo($hControl) = "Radio"

....

Case GetControlInfo($hControl) = "ListBox"

etc

Maybe giving us more info of what you are trying to do would help us out. Though I am not very smart, I cannot think of a situation where this would be helpful for you. The only way I could even dream of doing this currently would be to use through ControlCommand() option until you do not receive an @error of 1. Otherwise, my guess is we need more info of what you are doing to help out. Good Luck.

Share this post


Link to post
Share on other sites

The Class is Detectable with _WinAPI_GetClassName


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

The Class is Detectable with _WinAPI_GetClassName

MSDN: The GetClassName function retrieves the name of the class to which the specified window belongs.

I try use it and this function (GetClassName) return Class name of the window not control.

Maybe giving us more info of what you are trying to do would help us out.

Previously i have a lot of scripts created on Rational Visual Test and I want to convert them into Auto-It scripts.

I have some include file with more then 200 Control ID and I want to use this information.

Also I have a function such as SetProperty($ID, $Value) which get information about Type/Class of control and put appropriated information in Control.

I use RadioButtons/Buttons/EditText/ListBox etc.

Of course I could change definition of these existing ID and add this information into it but it's not perfect decision :)

I suppose that it should be possible to get the information about any control automatically if we could do this manually via AutoIt Window Info.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

All Controls are Windows :)

Use this:

$hwnd = ControlGetHandle("Wahtever","",1234)
$Class = _WInAPI_GetClassName($hwnd)

#include <GUIConstants.au3>
#include <WinAPI.au3>

#region - GUI Create
$GUI = GUICreate('GUI')
GUICtrlCreateLabel("Click Button, Label or Press {F10} to fetch Control/Window ClassInfo",50,10,300,30)
$x = GUICtrlCreateButton("hello",10,10)
$a = GUICtrlCreateLabel("",10,50,300,50)
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetFont(-1,12,800)
GUISetState()
#endregion
HotKeySet("{F10}","GetCntrlClass")
#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $x
            $hwnd = GUICtrlGetHandle($x)
            GUICtrlSetData($a,"Class of Button: " & _WinAPI_GetClassName($hwnd))
        Case $msg = $a
            $hwnd = ControlGetHandle($GUI,"",$a)
            GUICtrlSetData($a,"Class of Label: " & _WinAPI_GetClassName($hwnd))
    EndSelect
WEnd
#endregion

Func GetCntrlClass()
    $pos = _WinAPI_GetMousePos()
    $hwnd = _WinAPI_WindowFromPoint($pos)
    GUICtrlSetData($a,"Class of Control/Win under Mouse: " & @CRLF & _WinAPI_GetClassName($hwnd))
EndFunc
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

To ProgAndy:

The problem is that Class name for Radio buttons, Check box and buttons are "Button"

I still do not understand how to separate them if I have a handler and ID of Control.

Share this post


Link to post
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
Sign in to follow this  
Followers 0