- the control ClassNameNN changes often
- cannot obtain any information that uniquely identifies the control
Often times, we are stuck trying to identify them using less than robust means. Fortunately, there is the WM_GETCONTROLNAME message. Using this, one can identify a .NET control by the name given by the developer at design time ( or given at run-time ).
Attached is a port to AutoIT from a C++ example posted here.
NET_DumpAllControlNames will dump all control names for a given .NET Windows Form.
NET_ControlGetHandleByName will provide a handle for a given control name on a Windows Form
Example:
#include <DotNetIdentification.au3> ; "Test App" is a fictitous application that contains a control named "txtShowMe". $WindowName = "Test App" $WindowText = "" $control = NET_ControlGetHandleByName( $WindowName, $WindowText, "txtShowMe" ) if @error = 0 then WinActivate( $WindowName, $WindowText ) ControlFocus( $WindowName, $WindowText, $control ) endif
NOTE:
- Not all .NET controls have unique names assigned to them.
- Also, this will NOT provide access to cells in a .NET Data Grid. For those, take a look at MS Active Accessibility implemented in oleacc.dll and its AutoIT implementation here.
- If you wish to discover the names of specific controls using a utility similar to the AutoItInfo tool, check out Managed Spy or Ranorex Spy.
TODO:
- Break out Setup and Cleanup into distinct functions
- Fill out error handling
- Once registering OnAutoITExit functions is implemented, cleanup on errors
Attached Files
Edited by zfisherdrums, 24 October 2008 - 07:31 PM.





