c.haslam Posted December 23, 2018 Posted December 23, 2018 (edited) A script creates Dialog A. This dialog creates another dialog, B. While B is active, the user should not be able to activate Dialog A. When the user closes dialog B, A should activate. Clicking in Dialog A while Dialog B is active should have no effect. How can I achieve this? ai have done it in the past. but I have forgotten how. Edited December 25, 2018 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
pixelsearch Posted December 23, 2018 Posted December 23, 2018 To do that, I always liked the 3rd example of the wiki page Managing Multiple GUIs It's a great script, simple to understand and commented. I paste it below, adding a couple of mikell's GUISetState() to disable Gui1 while Gui2 is active (instead of disabling only Button2 as in the original script) expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; example of how to manage two GUIs simultaneously using the "advanced" parameter with GUIGetMsg : Yes ! (MessageLoop mode) ; a single While...WEnd loop which distinguishes between the two GUIs Global $g_hGUI2 = 9999 ; Predeclare this variable with dummy value to prevent firing the Case statement, only for GUI2 this time Global $g_idButton3 gui1() Func gui1() Local $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100) Local $idButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) Local $idButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUISetState() Local $aMsg While 1 $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array Switch $aMsg[1] ; check which GUI sent the message Case $hGUI1 Switch $aMsg[0] ; Now check for the messages for $hGUI1 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<< ExitLoop Case $idButton1 MsgBox($MB_OK, "MsgBox 1", "Test from Gui 1") Case $idButton2 ; GUICtrlSetState($idButton2, $GUI_DISABLE) GUISetState(@SW_DISABLE, $hGUI1) gui2() EndSwitch Case $g_hGUI2 Switch $aMsg[0] ; Now check for the messages for $g_hGUI2 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUIDelete($g_hGUI2) ; GUICtrlSetState($idButton2, $GUI_ENABLE) GUISetState(@SW_ENABLE, $hGUI1) GUISetState(@SW_RESTORE, $hGUI1) Case $g_idButton3 MsgBox($MB_OK, "MsgBox", "Test from Gui 2") EndSwitch EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $g_hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350) $g_idButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() EndFunc ;==>gui2 Good luck "I think you are searching a bug where there is no bug... don't listen to bad advice."
mLipok Posted December 23, 2018 Posted December 23, 2018 (edited) GuiCreate last param is 'parent' Just use them in second window GuiCreate - pass there returned hwnd from first gui. Edited December 23, 2018 by mLipok 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
Nine Posted December 23, 2018 Posted December 23, 2018 Nice work @pixelsearch An alternative where gui1 disappears completely : expandcollapse popup#include <GUIConstants.au3> #include <MsgBoxConstants.au3> Opt ("MustDeclareVars", 1) Global $hGUI1 gui1() Func gui1() $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100) Local $idButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) Local $idButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUISetState() While True Switch GUIGetMsg() ; Now check for the messages for $hGUI1 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<< ExitLoop Case $idButton1 MsgBox($MB_OK, "MsgBox 1", "Test from Gui 1") Case $idButton2 GUISetState(@SW_DISABLE, $hGUI1) gui2() EndSwitch WEnd GUIDelete ($hGUI1) EndFunc ;==>gui1 Func gui2() Local $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350) Local $idButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() GUISetState (@SW_HIDE, $hGUI1) While True Switch GUIGetMsg() ; Now check for the messages for $hGUI1 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUISetState (@SW_SHOW, $hGUI1) GUISetState(@SW_ENABLE, $hGUI1) GUISetState(@SW_RESTORE, $hGUI1) ExitLoop Case $idButton3 MsgBox($MB_OK, "MsgBox", "Test from Gui 2") EndSwitch Wend GUIDelete($hGUI2) EndFunc ;==>gui2 “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
yutijang Posted December 23, 2018 Posted December 23, 2018 How about this expandcollapse popup#include <GUIConstants.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) Global const $hGUI1_Title = "Gui 1" Global const $hGUI2_Title = "Gui 2" $hGUI1 = GUICreate($hGUI1_Title, 200, 200, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") Local $idButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUICtrlSetOnEvent(-1, "ShowGUI2") GUISetState(@SW_SHOW) Local $hGUI2 = GUICreate($hGUI2_Title, 200, 200, 350, 350) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") GUISetState(@SW_HIDE) While 1 Sleep(10) WEnd Func ShowGUI2() Local $pos_hGUI1 = WinGetPos($hGUI1_Title) WinMove($hGUI2, "", $pos_hGUI1[0], $pos_hGUI1[1]) GUISetState(@SW_SHOW, $hGUI2) GUISetState(@SW_HIDE, $hGUI1) EndFunc Func On_Close() Switch @GUI_WinHandle Case $hGUI1 Exit Case $hGUI2 Local $pos_hGUI2 = WinGetPos($hGUI2_Title) WinMove($hGUI1, "", $pos_hGUI2[0], $pos_hGUI2[1]) GUISetState(@SW_SHOW, $hGUI1) GUISetState(@SW_HIDE, $hGUI2) EndSwitch EndFunc
c.haslam Posted December 23, 2018 Author Posted December 23, 2018 Thank you all. mLipok's answer led me to finding my error. I had GuiCreate with hParent, but hParent was 0. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
mLipok Posted December 23, 2018 Posted December 23, 2018 Solved ? 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
UEZ Posted December 23, 2018 Posted December 23, 2018 Another example: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIConv.au3> Global Const $hGUI = GUICreate("Test", 361, 125, -1, -1) Global Const $iLabel = GUICtrlCreateLabel("GUI A", 24, 16, 187, 79) GUICtrlSetFont(-1, 50, 400, 0, "Arial") Global Const $iButton = GUICtrlCreateButton("Btn 4 GUI B", 256, 72, 75, 25) GUISetState(@SW_SHOW) Global $hGUI2, $iLabel2, $iButton2 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton $hGUI2 = GUICreate("Child", 361, 125, -1, -1, -1, -1, $hGUI) $iLabel2 = GUICtrlCreateLabel("GUI B", 24, 16, 187, 79) GUICtrlSetFont(-1, 50, 400, 0, "Arial") $iButton2 = GUICtrlCreateButton("Exit", 256, 72, 75, 25) GUISetState(@SW_SHOW, $hGUI2) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") While 1 Switch GUIGetMsg() Case $iButton2, $GUI_EVENT_CLOSE GUIRegisterMsg($WM_ACTIVATE, "") GUIDelete($hGUI2) ExitLoop EndSwitch WEnd EndSwitch WEnd Func WM_ACTIVATE($hWnd, $iMsgID, $wParam, $lParam) #forceref $iMsgID, $hWnd If $lParam = $hGUI2 And (_WinAPI_LoWord($wParam) = 2 Or _WinAPI_LoWord($wParam) = 1) Then WinActivate($hGUI2) EndIf Return $GUI_RUNDEFMSG EndFunc Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
c.haslam Posted December 25, 2018 Author Posted December 25, 2018 Yes, solved: thanks to MLipok. I will mark it as such. I am yet to digest UEZ's solution. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
c.haslam Posted December 25, 2018 Author Posted December 25, 2018 (edited) UEZ: I see that your example does: If Test is active, clicking the button activates Child If Child is active, clicking the button activates Test Is there a way to do this: When Child is active, clicking in Test (not in any control) activates Test and deactivates Child When Test is active, clicking in Child (not in any control) activates Child and deactivates Test Certainly safer would be: When Child is active, clicking in Test (in its title bar) activates Test and deactivates Child When Test is active, clicking in Child (in its title bar) activates Child and deactivates Test C Edited December 25, 2018 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
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