Jump to content

Need help detecting what ControlID that the user click..

Recommended Posts

I have:

None are overlapped... 
When I click on any of the above Controls, I want Autoit to call a function and perform tasks based on where the user clicked.
Currently, I am using
GUIRegisterMsg($WM_COMMAND,     "_LostFocus")
func _LostFocus($hWnd, $Msg, $wParam, $lParam)
    local $nNotifyCode = BitShift($wParam, 16)
    local $nID = BitAND($wParam, 0x0000FFFF)
    .....if $nNotifyCode is 256, then $nID is the ControlID that has focus (or click)
But it is not working properly when I clicked on tabs: $nID is not updated, and $nNotifyCode is 512...
I could use $nNotifyCode = 512 to mean user clicked on tabs but I still need to know which tab
Link to post
Share on other sites

In helpfile for GUICtrlCreateTabItem() is example for catching change of "active Tab":

#include <GUIConstantsEx.au3>


Func Example()
    GUICreate("My GUI Tab", 250, 150); will create a dialog box that when displayed is centered

    GUISetFont(9, 300)

    Local $idTab = GUICtrlCreateTab(10, 10, 200, 100)

    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    GUICtrlCreateInput("default", 80, 50, 70, 20)

    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon"); default Jon
    GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem(""); end tabitem definition

    GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20)


    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop
        If $idMsg = $idTab Then
            ; display the clicked tab
            WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($idTab))
EndFunc   ;==>Example


Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...