NoNameCode Posted December 2, 2022 Share Posted December 2, 2022 Hello people I found an interesting bug here related to GUIOnEvent & whether to hide GUI using GUISetSate or WinSetState. Compiled the code & run it 2x first execution: hide the GUI by clicking X (common e.g. for features like minimize to tray) second execution: a msgbox with the title "Singelton" signals that it was detected that the application is already running. The window with the title "Test" is displayed again. If one hid here in the function "_GUIOnEvent_GUIClose" the window use WinSetState OnEvent is active, if GUISetState was used OnEvent is inactive. (Use the Test button to test if onevent is active or inactive) #include <Misc.au3> AutoItSetOption("GUIOnEventMode", 1) If Not _Singleton("Test", 1) Then WinSetState("Test", "", @SW_SHOW) MsgBox(0, "_Singleton", "", 2) Exit EndIf $hGUI = GUICreate("Test", 100, 100) GUISetOnEvent(-3, "_GUIOnEvent_GUIClose") GUICtrlCreateButton("Test Button", 10, 10, 80, 80) GUICtrlSetOnEvent(-1, "_GUIOnEvent_Button_Test") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func _GUIOnEvent_Button_Test() MsgBox(0, "_GUIOnEvent_Button_Test", "") EndFunc Func _GUIOnEvent_GUIClose() ;~ WinSetState($hGUI, '', @SW_HIDE) ;==> OnEvent still aktiv GUISetState(@SW_HIDE) ;==> OnEvent somehow inakiv EndFunc regards NoNameCode Link to comment Share on other sites More sharing options...
Danp2 Posted December 2, 2022 Share Posted December 2, 2022 You may want to restate the issue because it isn't clear to me after reading your post. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
argumentum Posted December 2, 2022 Share Posted December 2, 2022 ..that GUISetState(@SW_HIDE) fails at times where WinSetState($hGUI, '', @SW_HIDE) works fine ( in my interpretation ) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 5, 2022 Moderators Share Posted December 5, 2022 Moved to the appropriate forum. Moderation Team "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
NoNameCode Posted December 5, 2022 Author Share Posted December 5, 2022 Okay so it's hard to understand, let me visual it a bit: Script Start -> GUI Build -> GUI Show -> Click Button -> CtrlOnEvent for this Button will trigger a MsgBox Case 1: Pressing X -> Hiding Windows use GUISetState(@SW_Hide) -> Start a Second Instans of the Script -> Singelton will notice and Return False -> Second Instanz Show the GUI with WinSetState(... @SW_Show) -> Click Button -> No Reaktion ; It seems to be that only GUISetState(@SW_Show) enables the CtrlOnEvent Routine Case 2: Pressing X -> Hiding Windows use WinSetState($hGUI, '', @SW_Hide) -> Start a Second Instans of the Script -> Singelton will notice and Return False -> Second Instanz Show the GUI with WinSetState(... @SW_Show) -> Click Button -> CrlOnEvent for this Button will trigger a MsgBox Is it a bug or a feature? Regards NoNameCode Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted December 5, 2022 Moderators Solution Share Posted December 5, 2022 NoNameCode, I raised the same point some years ago and a then-Dev told me that it was a design decision to block events when using GUISetState and that only that function should be used when dealing with AutoIt-created GUIs. Furthermore, it was suggested then the use of WinSetState on AutoIt GUIs could lead to unwelcome results, although, in the typically laconic style of that then-Dev, no hard facts as to what exactly might occur were forthcoming. So I would go for "feature". M23 NoNameCode 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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