Modify

Opened 2 weeks ago

Last modified 9 days ago

#3775 assigned Feature Request

INSTANCE ignored when ID also given in a ControlID

Reported by: AlanParry Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

For a ControlID like [ID:205;INSTANCE:2] the instance number is ignored and the first Control with ID=205 is always returned.
For example when used in an expression like:

Local $hBtn = ControlGetHandle ($hTopWnd, "", "[ID:205;INSTANCE:2]")

Yes I know its wierd to have 2 controls with the same ID but there's this program I'm trying to automate has 2 buttons in different panes that do the same action - but it's important that I get the control in the correct pane.

Tested in 3.3.14.5 and 3.3.15.3

Alan

Attachments (0)

Change History (5)

comment:1 Changed 2 weeks ago by Jpm

Can you post a complete small repro script so I can reproduce and hopefully fix it
Thanks

comment:2 Changed 2 weeks ago by anonymous

This shows it:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>

Example()

Func Example ()

    Const $ID = 123
    Const $style = $WS_CHILD+$WS_BORDER+$WS_VISIBLE

    Local $hGui = GuiCreate ("Test", 500, 120, 200, 200)

    ; use _WinAPI_CreateWindowEx to make controls with same ID
    Local $hwnd1 = _WinAPI_CreateWindowEx (0, "Static", "L1", $style, 5, 5, 230, 100, $hGui, $ID)
    Local $hwnd2 = _WinAPI_CreateWindowEx (0, "Static", "L2", $style, 255, 5, 230, 100, $hGui, $ID)
    GUISetState(@SW_SHOW, $hGUI)

    Local $hGet1 = ControlGetHandle ($hGui, "", "[ID:" & $ID & ";INSTANCE:1]")
    Local $hGet2 = ControlGetHandle ($hGui, "", "[ID:" & $ID & ";INSTANCE:2]")

    ControlSetText ($hwnd1, "", "", "HWnd is" & @TAB & $hWnd1 & @CRLF & "Got " & @TAB & @TAB & $hGet1)
    ControlSetText ($hwnd2, "", "", "HWnd is" & @TAB & $hWnd2 & @CRLF & "Got " & @TAB & @TAB & $hGet2 & @CRLF & @CRLF  & @TAB & "WRONG!!")

   While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

Alan

comment:3 Changed 2 weeks ago by Jpm

Thanks
I will have a look

comment:4 Changed 9 days ago by Jpm

  • Owner set to Jon
  • Status changed from new to assigned
  • Type changed from Bug to Feature Request

By design AutoIt priorise the ID and stop searching other properties.
I leave to Jon the decision to change this behavior.
I will add a comment in the doc.

comment:5 Changed 9 days ago by TicketCleanup

  • Version 3.3.14.5 deleted

Automatic ticket cleanup.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as assigned The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.