Hi,
I have created a bit of code to enable a script to find named controls on a userform, even though the MS CLASS description changes between machines.
e.g. The CLASS "WindowsForms10.EDIT.app.0.24b689f_r14_ad1" for a text box on one PC is different on another.
The below code, (a cut-down version of the code from jdelaney original post) loops through all the controls and finds the first one with the desired string in the control class name - in this case "EDIT". This name is then usable for setting the text using ControlSetText.
#include <array.au3>
WinActivate("Edit Part Rule")
$TheClassName = GetAllWindowsControls(WinGetHandle("Edit Part Rule"), "EDIT")
;Sleep(500)
ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:3]", $CmdLine[1])
ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:4]", $CmdLine[2])
Func GetAllWindowsControls($hCallersWindow, $sStringIncludes)
; Get all list of controls
$sClassList = WinGetClassList($hCallersWindow)
; Create array
$aClassList = StringSplit($sClassList, @CRLF, 2)
; Sort array
_ArraySort($aClassList)
_ArrayDelete($aClassList, 0)
; Loop
For $i = 0 To UBound($aClassList) - 1
If StringInStr($aClassList[$i], $sStringIncludes) Then
Return $aClassList[$i]
EndIf
Next
EndFunc ;==>GetAllWindowsControls
If anyone has any suggestions to improve it, or a better way to achieve the same thing, please let me know.