jdelaney Posted November 15, 2012 Share Posted November 15, 2012 (edited) My software I'm attempting to automate includes a Button that can be present any number of times, but only one will be visible at a time. I was hoping something like this would work $hApplication = "MyApplication" $giWebWorkList_ButtonAddToWorklist = 4642 ; The ID of the controls $iLoop = 1 While True $hAddToWorklist = ControlGetHandle($hApplication, "", "[CLASSNN:Button" & $iLoop & "; ID:" & $giWebWorkList_ButtonAddToWorklist & "]") If Not IsHWnd($hAddToWorklist) Then ConsoleWrite ( "exit, Failure, on loop=[" & $iLoop & "]" & @CRLF ) ExitLoop Else ConsoleWrite ( $iLoop & " " & $hAddToWorklist & @CRLF ) EndIf $bFound1 = ControlCommand($hApplication, "", $hAddToWorklist, "IsVisible", "") $bFound2 = ControlCommand($hApplication, "", $hAddToWorklist, "IsEnabled", "") If $bFound1 And $bFound2 Then ConsoleWrite ( "Found visible instance of buttonid=[]; where IsVisible=[" & $bFound1 & "] and IsEnabled=[" & $bFound2 & "] on Instance=[" & $iLoop & "]; Handle=[" & $hAddToWorklist & "]; id being searched=[" & $hAddToWorklist & "]." & @crlf ) ExitLoop EndIf $iLoop += 1 WEnd But in the ControlGetHandle function, BOTH the CLASSNN and ID are not conisidered, only the CLASSNN...so the first visible,enabled, button is returned, regardless of the ID NOT being the one I'm searching for. I also attempted using the ID, and Instance: $hAddToWorklist = ControlGetHandle($hApplication, "", "[ID:" & $giWebWorkList_ButtonAddToWorklist & "; INSTANCE:" & $iLoop & "]") But the instance param is not considered, it only returns the first applicable control matching the ID Please let me know of a workaround...or, is there a way to take a handle, and return it's control's ID? If so, that would solve my problem...thanks! Edited November 15, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
jdelaney Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) Found a workaround...all the buttons share the same position, so I'm looping through all buttons until I find the visible one with the proper posistion...would still much rather be able to get the control ID from the handle...(if the autoit windo winfo tool can do it, why can't I ) Edited November 15, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
jdelaney Posted November 16, 2012 Author Share Posted November 16, 2012 bump: does anyone know how to get a control ID from a handle? IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
HeJake Posted November 17, 2012 Share Posted November 17, 2012 (edited) F1 #include <WinAPI.au3> _Main() Func _Main() Local $button GUICreate("test") $button = GUICtrlCreateButton("testing", 0, 0) MsgBox(4096, "ID", "Dialog Control ID: " & _WinAPI_GetDlgCtrlID(GUICtrlGetHandle($button))) EndFunc This is what u mean? Edited November 17, 2012 by HeJake Link to comment Share on other sites More sharing options...
jdelaney Posted November 19, 2012 Author Share Posted November 19, 2012 Perfect! Thanks. (need to look through all those winapi funcs more carefully. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
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