this snippet; Case $idDummy
Switch GUICtrlRead($tab)
Case 0
_GUICtrlButton_Click($idButton_1)
Case 1
_GUICtrlButton_Click($idButton_2)
EndSwitch
EndSwitch
can be like this: Case $idDummy
_GUICtrlButton_Click($idButton_1)
_GUICtrlButton_Click($idButton_2)
EndSwitch
But if you want really click both button on different TabItem then you must use GuiSwitch like this: #include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
_Example()
Func _Example()
Local $hGUI = GUICreate("My GUI Tab", 210, 110) ; will create a dialog box that when displayed is centered
Local $idDummy = GUICtrlCreateDummy()
$tab = GUICtrlCreateTab(10, 10, 200, 100)
Local $idTabItem_1 = GUICtrlCreateTabItem("tab 1")
Local $idButton_1 = GUICtrlCreateButton("Tab 1", 20, 50, 50, 20)
Local $idTabItem_2 = GUICtrlCreateTabItem("tab 2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
Local $idButton_2 = GUICtrlCreateButton("Tab 2", 140, 50, 50)
GUICtrlCreateTabItem(""); end tabitem definition
Local $aAccelKeys[1][2] = [["{Enter}", $idDummy]]
GUISetAccelerators($aAccelKeys)
GUISetState(@SW_SHOW)
Local $idMsg
; Loop until the user exits.
Local $idActiveTabItem
While 1
; You can not click $idButton_1 when Tab2 is active
; I think this is normal Windows GUI behavior
;_GUICtrlButton_Click($idButton_1)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton_1
MsgBox(0, 'Test', "But1")
Case $idButton_2
MsgBox(0, 'Test', "But2")
Case $idDummy
$idActiveTabItem = GUICtrlRead($tab)
Switch $idActiveTabItem
Case 0
_GUICtrlButton_Click($idButton_1)
GUISwitch($hGUI ,$idTabItem_2)
_GUICtrlButton_Click($idButton_2)
Case 1
_GUICtrlButton_Click($idButton_2)
GUISwitch($hGUI ,$idTabItem_1)
_GUICtrlButton_Click($idButton_1)
EndSwitch
GUISwitch($hGUI ,$idActiveTabItem)
EndSwitch
WEnd
EndFunc ;==>_Example