wuruoyu Posted October 13, 2017 Share Posted October 13, 2017 (edited) When switching tab, the "File" menu is highlighted just like when pressing the "ALT" key on keyboard (especially when I keep holding down the left click on the tab). Is there anyway to avoid the "File" menu being highlighted when switching tab and retain the accelerator "ALT" when press "ALT" key on keyboard. Thanks in advance! I know this is not the standard way to setup tab control, but have to use this method to fix other issues I have had: *Seems like ALT is being triggered when GUISetState(@SW_HIDE) or GUISetState(@SW_SHOW) is used in my case expandcollapse popup#NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <EditConstants.au3> #include <GUIToolbar.au3> #include <GUIImageList.au3> #include <WinAPITheme.au3> Opt("GUIOnEventMode", 1) Global $tab, $currentTab, $pageOneGUI, $pageTwoGUI Global $idInput1P2, $idInput2P2, $idInput3P2 _main() Func _main() $main = GUICreate("main", 368, 363, -1, -1, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idFileitem = GUICtrlCreateMenuItem("Open", $idFilemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) Local $idHelpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $idFilemenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $idInfoitem = GUICtrlCreateMenuItem("Info", $idHelpmenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idRecentfilesmenu = GUICtrlCreateMenu("Recent Files", $idFilemenu, 1) $ToolbarGUI = GUICreate('', 350, 62, 1, 1, $WS_CHILD, 0, $main) $Toolbar = _GUICtrlToolbar_Create($ToolbarGUI, BitOR($BTNS_BUTTON, $BTNS_SHOWTEXT, $TBSTYLE_FLAT, $TBSTYLE_TOOLTIPS), $TBSTYLE_EX_DOUBLEBUFFER) $ToolbarImageList = _GUIImageList_Create(32, 32, 5, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\mmc.exe", 0, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\cmd.exe", 0, 1) _GUICtrlToolbar_SetImageList($Toolbar, $ToolbarImageList) _GUICtrlToolbar_AddString($Toolbar, 'MMC') _GUICtrlToolbar_AddString($Toolbar, 'CMD') _GUICtrlToolbar_AddButton($Toolbar, 10000, 0, 0) _GUICtrlToolbar_AddButton($Toolbar, 10001, 1, 1) _GUICtrlToolbar_SetButtonSize($Toolbar, 62, 50) _GUICtrlToolbar_SetMetrics($Toolbar, 0, 0, 1, 0) _GUICtrlToolbar_SetIndent($Toolbar, 1) _SendMessage($Toolbar, $TB_AUTOSIZE) GUISwitch($main) GUICtrlCreateLabel('', 0, 63, 368, 2, $SS_ETCHEDHORZ) GUICtrlCreateButton("button", 248, 313, 100, 20, -1, -1) $pageOneGUI = GUICreate("", 352, 198, 9, 93, $WS_CHILD,-1, $main) ;GUISetBkColor(0xCCFFCC) GUICtrlCreateGroup("Group", 6, 3, 341, 180, -1, -1) GUICtrlCreateEdit("this is an edit control", 15, 40, 325, 67, BitOR($ES_READONLY, $WS_VSCROLL), $WS_EX_CLIENTEDGE) GUICtrlCreateInput("This is an inputbox", 15, 130, 325, 20, -1, $WS_EX_CLIENTEDGE) $pageTwoGUI = GUICreate("", 352, 198, 9, 93, $WS_CHILD,-1, $main) ;GUISetBkColor(0xCCFFCC) $idInput1P2 = GUICtrlCreateInput("This is an inputbox", 15, 070, 325, 20, -1, $WS_EX_CLIENTEDGE) $idInput2P2 = GUICtrlCreateInput("This is an inputbox", 15, 100, 325, 20, -1, $WS_EX_CLIENTEDGE) $idInput3P2 = GUICtrlCreateInput("This is an inputbox", 15, 130, 325, 20, -1, $WS_EX_CLIENTEDGE) GUISwitch($main) $tab = GUICtrlCreateTab(4, 70, 363, 226, -1, -1) GUICtrlSetOnEvent($Tab, "_tabChangeDetected") GUICtrlCreateTabItem("Page 1") GUICtrlCreateTabItem("Page 2") GUICtrlCreateTabItem("") _WinAPI_SetWindowTheme(GUICtrlGetHandle( $tab ), "", "") $currentTab = _GUICtrlTab_GetCurFocus($tab) $idTabKeyP2 = GUICtrlCreateDummy() GUICtrlSetOnEvent( $idTabKeyP2, "TabKeyP2" ) Local $aAccelKeys[1][2] = [["{Tab}", $idTabKeyP2]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOWNOACTIVATE, $ToolbarGUI) GUISetState(@SW_SHOW, $main) _GUICtrlTab_SetCurFocus($tab, 0) While 1 Sleep(100) WEnd EndFunc ;==>_main Func TabKeyP2() Switch _WinAPI_GetDlgCtrlID( ControlGetHandle( $pageTwoGUI, "", ControlGetFocus( $pageTwoGUI ) ) ) Case $idInput1P2 ControlFocus( $pageTwoGUI, "", $idInput2P2 ) Case $idInput2P2 ControlFocus( $pageTwoGUI, "", $idInput3P2 ) Case $idInput3P2 ControlFocus( $pageTwoGUI, "", $idInput1P2 ) Case Else EndSwitch EndFunc Func _exit() Exit EndFunc ;==>_exit Func _tabChangeDetected() If _GUICtrlTab_GetCurFocus($tab) <> $currentTab Then $currentTab = _GUICtrlTab_GetCurFocus($tab) ;MsgBox(0, "", $currentTab) Switch $currentTab Case 0 GUISetState(@SW_HIDE,$pageTwoGUI) GUISetState(@SW_SHOW,$pageOneGUI) Case 1 GUISetState(@SW_HIDE,$pageOneGUI) GUISetState(@SW_SHOW,$pageTwoGUI) EndSwitch EndIf EndFunc ;==>_tabChangeDetected Edited October 13, 2017 by wuruoyu Link to comment Share on other sites More sharing options...
wuruoyu Posted October 14, 2017 Author Share Posted October 14, 2017 Bump Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 14, 2017 Moderators Share Posted October 14, 2017 I can see this happening when you're using hide method because you're not focusing on that GUI any longer, now it's shifted back to the main gui before focus is again giving to the alternate page GUI. I'm curious, if you put say Sleep(100) between the hide and show in the tab changed detected function... do you still get the same result? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
wuruoyu Posted October 14, 2017 Author Share Posted October 14, 2017 Thank you for your reply, SmOke_N. I tried adding Sleep(100) between the hide and show, it's the same result. Link to comment Share on other sites More sharing options...
mLipok Posted October 14, 2017 Share Posted October 14, 2017 Offtopic: Nice to see you again @SmOke_N Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 14, 2017 Moderators Share Posted October 14, 2017 (edited) Have you tried using controlhide/show instead? I can't replicate it, on mine, it highlights as expected then when the new GUI is given show state the highlight goes away as expected. eg.. Func _tabChangeDetected() If _GUICtrlTab_GetCurFocus($tab) <> $currentTab Then $currentTab = _GUICtrlTab_GetCurFocus($tab) ;MsgBox(0, "", $currentTab) Switch $currentTab Case 0 ControlHide($main, "", $pageTwoGUI) ControlShow($main, "", $pageOneGUI) ;~ GUISetState(@SW_HIDE,$pageTwoGUI) ;~ GUISetState(@SW_SHOW,$pageOneGUI) Case 1 ControlHide($main, "", $pageOneGUI) ControlShow($main, "", $pageTwoGUI) ;~ GUISetState(@SW_HIDE,$pageOneGUI) ;~ GUISetState(@SW_SHOW,$pageTwoGUI) EndSwitch EndIf EndFunc ;==>_tabChangeDetected Edit: @mLipok hope you're doing well! Edited October 14, 2017 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mLipok Posted October 14, 2017 Share Posted October 14, 2017 1 hour ago, SmOke_N said: @mLipok hope you're doing well! Thanks, apart from lack of sleep and money I do not complain Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
wuruoyu Posted October 14, 2017 Author Share Posted October 14, 2017 @SmOke_N Thank you so much for the fix, it works! 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