jacksonm1234 Posted December 7, 2012 Posted December 7, 2012 Greetings! I'm trying to interact with a button on a form using the ControlCommand Function. All I want to do is see if this button is enabled or not. The button's text is "&Find" as determined by the window info tool and by ControlGetText. In testing, this works fine when I use this command (i.e. I get the expected 1 or 0): ControlCommand("Find - Account","","[CLASS:TRT6CommandButton; INSTANCE:3; ]","IsEnabled","") However, I would really like to get this function working by also specifying the TEXT command, but I can't seem to get it to work. This is the code that I use that always returns 0, like it's not seeing the button. ControlCommand("Find - Account","","[CLASS:TRT6CommandButton; INSTANCE:3; TEXT:&Find ]","IsEnabled","") Does anyone have any idea why I can't get the TEXT parameter to work??
Moderators Melba23 Posted December 7, 2012 Moderators Posted December 7, 2012 jacksonm1234,First question - If it works without the TEXT parameter, why do you insist on using it? Next question - Are you sure that the button text includes the "&"? Have you tried without that character? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jacksonm1234 Posted December 7, 2012 Author Posted December 7, 2012 Hi Melba, 1. I plan on using this for multiple windows (that has the same find button), and I would just feel more comfortable if I could specify EXACTLY what button I need, rather than hoping that the class and instance number would be the same across all the windows. 2. Yeah, I tried it without the ampersand, with the same result. I also tried putting the text in double-double quotes in case the function needed that, but that didn't work either. This is so strange. I feel like this should be very straightforward and easy.
Moderators Melba23 Posted December 7, 2012 Moderators Posted December 7, 2012 jacksonm1234, Can you please post what you get when using the Autoit Window Info tool on the GUI - that might give us a clue. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jdelaney Posted December 7, 2012 Posted December 7, 2012 (edited) A developer would need to verify, but you can't use infiinte params. The use of some seems to negate others. Such as, if you use ID, the INSTANCE is disregarded. I think it would be nice if the exact logic of getting controls was provided, somewhere. What you would need to do, is drop the Instance: ControlCommand("Find - Account","","[CLASS:TRT6CommandButton; TEXT:&Find ]","IsEnabled","") note: if there truely are 3 instances of the &Find button, then you will need to go about this another way. note2: maybe the order of the params is key...again, need a developer Edited December 7, 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.
jacksonm1234 Posted December 7, 2012 Author Posted December 7, 2012 Sure, here are all the items, copied and pasted since I don't know how to put a screenshot in my post. >>>> Control <<<< Class: TRT6CommandButton Instance: 3 ClassnameNN: TRT6CommandButton3 Name: Advanced (Class): [CLASS:TRT6CommandButton; INSTANCE:3] ID: 8 Text: &Find Position: 27, 220 Size: 71, 20 ControlClick Coords: 45, 8 Style: 0x54012001 ExStyle: 0x00000004 Handle: 0x001A0F06
jacksonm1234 Posted December 7, 2012 Author Posted December 7, 2012 I got it guys. After I thought a little more about by double-double quote idea, I realized that this command (which doesn't work)... ControlCommand("Find - Account","","[CLASS:TRT6CommandButton; INSTANCE:3; TEXT:&Find ]","IsEnabled","") ...has an extra space after &Find. So I was trying to look for a button that was "&Find " rather than correctly looking for "&Find". It works now. Sorry I wasted your time with a stuipid mistake!
jdelaney Posted December 7, 2012 Posted December 7, 2012 (edited) but technically, that's the third instance of CLASS:TRT6CommandButton...and not the 3rd instance of a &Find which is CLASS:TRT6CommandButton.I might start my own thread on this one.update, it seems the only issue is when you use ID, and attempt to use Instance.this proves you can use instance, and class, and text:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example1() ; example 1 Func Example1() Local $msg $hGui = GUICreate("My GUI", 320, 150) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box Dim $aControls[4][2] GUICtrlCreateButton ( "NEW", 5,5,50,25) $aControls[0][0] = GUICtrlCreateButton ( "TEST", 5,30,50,25) $aControls[1][0] = GUICtrlCreateButton ( "TEST", 5,55,50,25) $aControls[2][0] = GUICtrlCreateButton ( "TEST", 5,80,50,25) $aControls[3][0] = GUICtrlCreateButton ( "TEST", 5,105,50,25) $aControls[0][1] = ControlGetHandle ( $hGui, "", $aControls[0][0] ) $aControls[1][1] = ControlGetHandle ( $hGui, "", $aControls[1][0] ) $aControls[2][1] = ControlGetHandle ( $hGui, "", $aControls[2][0] ) $aControls[3][1] = ControlGetHandle ( $hGui, "", $aControls[3][0] ) $hGui = WinGetHandle ( "My GUI" ) For $i = 0 To UBound ( $aControls ) - 1 $hTemp = ControlGetHandle ( $hGui, "", "[CLASS:Button; INSTANCE:" & $i+2 & "]" ) If $aControls[$i][1] <> $hTemp Then ConsoleWrite ("Proper handle NOT returned for [CLASS:Button; INSTANCE:" & $i+2 & "]; Data returned=[" &$hTemp & "]; Data Expected=[" & $aControls[$i][1] & "]." & @CRLF ) Else ConsoleWrite ("Proper handle returned for [CLASS:Button; INSTANCE:" & $i+2 & "]; Data returned=[" &$hTemp & "]; Data Expected=[" & $aControls[$i][1] & "]." & @CRLF ) EndIf Next For $i = 0 To UBound ( $aControls ) - 1 $hTemp = ControlGetHandle ( $hGui, "", "[CLASS:Button; INSTANCE:" & $i+1 & "; TEXT:TEST]" ) If $aControls[$i][1] <> $hTemp Then ConsoleWrite ("Proper handle NOT returned for [CLASS:Button; INSTANCE:" & $i+1 & "; TEXT:TEST]; Data returned=[" & $hTemp & "]; Data Expected=[" & $aControls[$i][1] & "]." & @CRLF ) Else ConsoleWrite ("Proper handle returned for [CLASS:Button; INSTANCE:" & $i+1 & "; TEXT:TEST]; Data returned=[" & $hTemp & "]; Data Expected=[" & $aControls[$i][1] & "]." & @CRLF ) EndIf Next ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>Example1 Edited December 7, 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.
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