Silverlode Posted November 3, 2015 Posted November 3, 2015 Hi, I've searched and not come up with much. I would like to get the controlID of a text label based on what the text is. So, if I have several labels in a WindowsForm and one of them is "This Text String", I want to get the controlID of that particular label. I haven't found a way to get that, based on the text in the control. Any ideas out there?I appreciate it.
Silverlode Posted November 3, 2015 Author Posted November 3, 2015 More specifically I need to get the classnameNN from the text string. I did figure out to use ControlGetHandle to get the handle of the controlID, but now I need to get the classnameNN of that handle.
JohnOne Posted November 3, 2015 Posted November 3, 2015 More specifically I need to get the classnameNN from the text string. I did figure out to use ControlGetHandle to get the handle of the controlID, but now I need to get the classnameNN of that handle._WinAPI_GetClassName AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Silverlode Posted November 3, 2015 Author Posted November 3, 2015 Thanks JohnOne, that returns the class, not the classnameNN.
JohnOne Posted November 3, 2015 Posted November 3, 2015 Do you actually know what the classnameNN is, or what you intend to do with it? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Silverlode Posted November 3, 2015 Author Posted November 3, 2015 The classnameNN changes from machine to machine, installation to installation, for this particular dialog. I need to get the classnameNN of a particular label (the text in that label is always the same), so that I can reference another label (which has text that changes) and read its text.Basically I'm trying to read the version number of an installed piece of software from a dialog that lists a bunch of Excel extensions.
JohnOne Posted November 3, 2015 Posted November 3, 2015 ClassNameNN has no meaning at all outside the the internals of AutoIt, you realize that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Silverlode Posted November 3, 2015 Author Posted November 3, 2015 I actually solved this another way by creating an array from all the controls within a dialog, and sorting to find what I needed. Thanks.
JohnOne Posted November 3, 2015 Posted November 3, 2015 Hi, can you post solution please? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Silverlode Posted November 3, 2015 Author Posted November 3, 2015 Func WinListChildren($hWnd, ByRef $avArr) If UBound($avArr, 0) <> 2 Then Local $avTmp[10][2] = [[0]] $avArr = $avTmp EndIf Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD) While $hChild If $avArr[0][0]+1 > UBound($avArr, 1)-1 Then ReDim $avArr[$avArr[0][0]+10][2] $avArr[$avArr[0][0]+1][0] = $hChild $avArr[$avArr[0][0]+1][1] = _WinAPI_GetWindowText($hChild) $avArr[0][0] += 1 WinListChildren($hChild, $avArr) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd ReDim $avArr[$avArr[0][0]+1][2] EndFunc Global $avChildren Local $hWinHan = ControlGetHandle("Options", "", "[CLASS:WindowsForms10.Window.8.app.0.27c59a_r77_ad1; INSTANCE:2]") Sleep($sm_sleep) WinListChildren($hWinHan, $avChildren) Local $vValue = "Hyperion Strategic Planning" Sleep($sm_sleep) $ArrIndex = _ArraySearch($avChildren, $vValue) $ArrIndexVersion = $ArrIndex - 2 Local $iStart_Row = $ArrIndexVersion $VersionString = _ArrayToString($avChildren, "|", $ArrIndexVersion, $ArrIndexVersion, "-", 1, 1) Global $buildno = $VersionString Sleep($sm_sleep) Local $LogMsg = "INFO: Installed version is " & $buildno & "." _FileWriteLog(@ScriptDir & $logfile, $LogMsg)
junkew Posted November 3, 2015 Posted November 3, 2015 why not using [REGEXPCLASS:LABEL.*] in combination with INSTANCE:nn?What is AU3INF or simplespy (see examples section) giving back for properties for the element you are interested in? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now