Jump to content

ControlID TEXT help


Recommended Posts

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??

Link to comment
Share on other sites

  • Moderators

jacksonm1234,

First question - If it works without the TEXT parameter, why do you insist on using it? :huh:

Next question - Are you sure that the button text includes the "&"? Have you tried without that character? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 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

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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:

#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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...