TXTechie Posted September 9, 2020 Posted September 9, 2020 (edited) Hello Everyone, I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar. I've searched through the forums, but I'm not sure how to get started. Any ideas or functions to research are appreciated! Regards, TX Techie Edited September 9, 2020 by TXTechie
TXTechie Posted September 9, 2020 Author Posted September 9, 2020 Well, so much for my forum searching skills. Thank you, @faustf. I'll take a look at those message threads that you shared with me. I really appreciate your help!
Trong Posted September 9, 2020 Posted September 9, 2020 expandcollapse popup#include <GUIConstantsEx.au3> ; Create a GUI with various controls. Global $hGUI = GUICreate("Example", 300, 100, -1, -1) Global $idOK = GUICtrlCreateButton("OK", 10, 70, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Global $iTimeRestoreWindowsEG_1 = 5000 Global $iTimeRestoreWindowsEG_2 = 2500 AdlibRegister("_RestoreWindows_EG_1", $iTimeRestoreWindowsEG_1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $idOK MsgBox(0, "", "OK Press") Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE ConsoleWrite('$GUI_EVENT_MINIMIZE' & @CRLF) GUISetState(@SW_MINIMIZE, $hGUI) AdlibRegister("_RestoreWindows_EG_2", $iTimeRestoreWindowsEG_2) EndSwitch WEnd Func _RestoreWindows_EG_1() ConsoleWrite('_RestoreWindows_EG_1()' & @CRLF) GUISetState(@SW_RESTORE, $hGUI) EndFunc ;==>_RestoreWindows_EG_1 Func _RestoreWindows_EG_2() ConsoleWrite('_RestoreWindows_EG_2()' & @CRLF) GUISetState(@SW_RESTORE, $hGUI) AdlibUnRegister("_RestoreWindows_EG_2") EndFunc ;==>_RestoreWindows_EG_2 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
TXTechie Posted September 9, 2020 Author Posted September 9, 2020 That's a great script, @VIP! My current GUI script uses OnEvent mode, do I need to modify your script any in order to use it in OnEvent mode?
Trong Posted September 9, 2020 Posted September 9, 2020 F1 expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Create a GUI with various controls. Global $hGUI = GUICreate("Example", 300, 100, -1, -1) Global $idOK = GUICtrlCreateButton("OK", 10, 70, 85, 25) GUICtrlSetOnEvent(-1, "OK_Pressed") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Global $iTimeRestoreWindowsEG_1 = 5000 Global $iTimeRestoreWindowsEG_2 = 2500 AdlibRegister("_RestoreWindows_EG_1", $iTimeRestoreWindowsEG_1) ; Loop until the user exits. While 1 ;~ Switch GUIGetMsg() ;~ Case $idOK ;~ OK_Pressed() ;~ Case $GUI_EVENT_CLOSE ;~ ConsoleWrite('$GUI_EVENT_CLOSE' & @CRLF) ;~ Exit ;~ Case $GUI_EVENT_MINIMIZE ;~ ConsoleWrite('$GUI_EVENT_MINIMIZE' & @CRLF) ;~ GUISetState(@SW_MINIMIZE, $hGUI) ;~ AdlibRegister("_RestoreWindows_EG_2", $iTimeRestoreWindowsEG_2) ;~ EndSwitch WEnd Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ConsoleWrite('$GUI_EVENT_CLOSE' & @CRLF) Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ConsoleWrite('$GUI_EVENT_MINIMIZE' & @CRLF) GUISetState(@SW_MINIMIZE, $hGUI) AdlibRegister("_RestoreWindows_EG_2", $iTimeRestoreWindowsEG_2) Case @GUI_CtrlId = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents Func OK_Pressed() ConsoleWrite('OK_Pressed()' & @CRLF) MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>OK_Pressed Func _RestoreWindows_EG_1() ConsoleWrite('_RestoreWindows_EG_1()' & @CRLF) GUISetState(@SW_RESTORE, $hGUI) EndFunc ;==>_RestoreWindows_EG_1 Func _RestoreWindows_EG_2() ConsoleWrite('_RestoreWindows_EG_2()' & @CRLF) GUISetState(@SW_RESTORE, $hGUI) AdlibUnRegister("_RestoreWindows_EG_2") EndFunc ;==>_RestoreWindows_EG_2 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
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