kjpolker Posted September 1, 2021 Share Posted September 1, 2021 Hello, I would like to figure out a way to manipulate a control on one tab when inside another. Let me break it down: expandcollapse popup#include <GUIConstantsEx.au3> $GUI = GUICreate("Title", 281, 316) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("Exit"&@TAB&"F12", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("&Options") $MenuItem5 = GUICtrlCreateMenu("&Help") $MenuItem6 = GUICtrlCreateMenuItem("About", $MenuItem5) GUICtrlCreateGroup("", -99, -99, 1, 1) $Tab1 = GUICtrlCreateTab(0, 0, 280, 295) GUICtrlCreateTabItem("Tab 1") $Button1 = GUICtrlCreateButton("Start", 112, 144, 81, 33) GUICtrlCreateTabItem("Tab 2") GUICtrlCreateTabItem("Tab 3") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### HotKeySet("{F1}", "Test") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MenuItem6 MsgBox(64, "About", "Info.") Case $GUI_EVENT_CLOSE, $MenuItem2 Exit Case $Button1 If GUICtrlRead($Button1) = "Start" Then GUICtrlSetData($Button1, "Stop") Else GUICtrlSetData($Button1, "Start") EndIf EndSwitch WEnd Func Test() ;Call for button click ControlClick("Title", "Stop", 11) EndFunc The code above has 3 tabs and a button in the first. The button toggles between Start and Stop, nothing more. When pressing the F1 key it calls to Press the "Stop" button, which works flawless when Tab1 is shown, but does nothing when on Tab2 or Tab3. Is there a way to simulate this or call for the execution? Link to comment Share on other sites More sharing options...
Solution Nine Posted September 1, 2021 Solution Share Posted September 1, 2021 (edited) Here two ways to do this : expandcollapse popup#include <GUIConstantsEx.au3> $GUI = GUICreate("Title", 281, 316) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("Exit" & @TAB & "F12", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("&Options") $MenuItem5 = GUICtrlCreateMenu("&Help") $MenuItem6 = GUICtrlCreateMenuItem("About", $MenuItem5) GUICtrlCreateGroup("", -99, -99, 1, 1) $Tab = GUICtrlCreateTab(0, 0, 280, 295) $Tab1 = GUICtrlCreateTabItem("Tab 1") $Button1 = GUICtrlCreateButton("Start", 112, 144, 81, 33) $Tab2 = GUICtrlCreateTabItem("Tab 2") $Tab3 = GUICtrlCreateTabItem("Tab 3") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) $idDummy = GUICtrlCreateDummy() HotKeySet("{F1}", "Test") HotKeySet("{F2}", "Test2") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $MenuItem2 Exit Case $idDummy ContinueCase Case $Button1 If GUICtrlRead($Button1) = "Start" Then GUICtrlSetData($Button1, "Stop") Else GUICtrlSetData($Button1, "Start") EndIf EndSwitch WEnd Func Test() Local $iTab = GUICtrlRead($Tab, $GUI_READ_EXTENDED) Local $idTab = @extended If $iTab <> 0 Then GUISwitch($GUI, $Tab1) ControlClick($GUI, "", 11) If $iTab <> 0 Then GUISwitch($GUI, $idTab) EndFunc ;==>Test Func Test2() GUICtrlSendToDummy($idDummy) EndFunc Edited September 1, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JockoDundee Posted September 1, 2021 Share Posted September 1, 2021 In any event, don’t hardcode controlIDs. ControlClick("Title", "Stop", 11) You will regret it. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Zedna Posted September 1, 2021 Share Posted September 1, 2021 expandcollapse popup#include <GUIConstantsEx.au3> $GUI = GUICreate("Title", 281, 316) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("Exit"&@TAB&"F12", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("&Options") $MenuItem5 = GUICtrlCreateMenu("&Help") $MenuItem6 = GUICtrlCreateMenuItem("About", $MenuItem5) GUICtrlCreateGroup("", -99, -99, 1, 1) $Tab1 = GUICtrlCreateTab(0, 0, 280, 295) GUICtrlCreateTabItem("Tab 1") $Button1 = GUICtrlCreateButton("Start", 112, 144, 81, 33) GUICtrlCreateTabItem("Tab 2") GUICtrlCreateTabItem("Tab 3") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### HotKeySet("{F1}", "Test") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MenuItem6 MsgBox(64, "About", "Info.") Case $GUI_EVENT_CLOSE, $MenuItem2 Exit Case $Button1 DoButton1() EndSwitch WEnd Func Test() ;Call for button click ;~ ControlClick("Title", "Stop", 11) ;~ ControlClick($GUI, "", $Button1) DoButton1() EndFunc Func DoButton1() If GUICtrlRead($Button1) = "Start" Then GUICtrlSetData($Button1, "Stop") Else GUICtrlSetData($Button1, "Start") EndIf EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
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