lIlIIlIllIIIIlI Posted August 3, 2024 Posted August 3, 2024 (edited) I only noticed recently that with these gui pop-up things (dialogs?) open, you can still interact with the main gui, it all gets queued and processed once the dialog is closed. I find that disabling the main gui using @SW_DISABLE works for preventing this. The problem I have is restoring the main gui, or bringing the window back to focus? @SW_ENABLE works for re-enabling input, but it does not bring the window back to the forefront in focus, the window is like minimized or something. @SW_RESTORE seems to bring the window back to focus, but the entire gui disappears and then reappears very quickly, giving it a weird stuttering appearance, it doesn't feel smooth. I don't see a way to fully emulate how other programs handle dialogs using any of the options with GUISetState. I see other programs block input to the main gui and the cause the open dialog window to jiggle or flash as if to get your attention. I'm not worried about getting that attention jiggle so much as not having a stutter when the main gui is restored after being disabled. Help is much appreciated, thanks. Enable() ;Msgbox or other dialog Disable() func Disable() GUISetState(@SW_DISABLE , $gui) endfunc func Enable() GUISetState(@SW_ENABLE , $gui) GUISetState(@SW_RESTORE , $gui) endfunc Edited August 3, 2024 by lIlIIlIllIIIIlI typos
pixelsearch Posted August 3, 2024 Posted August 3, 2024 Hello, have you tried the last parameter ($hWnd) of these functions ?
Nine Posted August 3, 2024 Posted August 3, 2024 It would have been nice to get a full runable snippet, so we don't have to create it ourselves. Anyway, I tested with WinActivate instead of @SW_RESTORE, and on my side it working without any flickers “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
lIlIIlIllIIIIlI Posted August 3, 2024 Author Posted August 3, 2024 (edited) 6 hours ago, Nine said: It would have been nice to get a full runable snippet, so we don't have to create it ourselves. Anyway, I tested with WinActivate instead of @SW_RESTORE, and on my side it working without any flickers I usually feel bad about posting my code because I don't use the proper variable naming or anything else like everyone else on this site, but this demonstrates what I meant by 'stutter'. Just focus on the background main gui after you select a file and open. For me at least it disappears and then reappears almost instantly and it looks weird. I have tried subbing in WinActivate for @SW_RESTORE but it still looks the same, you can uncomment it and then comment @SW_RESTORE and try it out in the Enable func. expandcollapse popupOpt('GUIOnEventMode', 1) $gui = GUICreate('Example', 350,350) GUISetFont(10) guictrlcreatelabel('Video list',10,10, 100, 20) GUICtrlCreateList('', 10, 30, 330, 100) GUICtrlCreateButton('Add videos', 10, 120, 330, 25) GUICtrlSetOnEvent(-1, "Add") GUISetOnEvent(-3, 'Close') GUISetState() func Add() Disable() FileOpenDialog('Open video ...', @ScriptDir, 'Videos (*.mkv;*.mp4)', 0x7) Enable() endfunc while 1 sleep(1000) wend func Disable() GUISetState(@SW_DISABLE , $gui) endfunc func Enable() GUISetState(@SW_ENABLE , $gui) GUISetState(@SW_RESTORE , $gui) ;WinActivate($gui) endfunc func Close() exit endfunc Edited August 3, 2024 by lIlIIlIllIIIIlI
lIlIIlIllIIIIlI Posted August 3, 2024 Author Posted August 3, 2024 6 hours ago, pixelsearch said: Hello, have you tried the last parameter ($hWnd) of these functions ? Wouldn't that be $gui in the example I posted? GUISetState(@SW_DISABLE , $gui) Or do you mean omitting it? I tried without it and it functions the same.
Nine Posted August 3, 2024 Posted August 3, 2024 1 hour ago, lIlIIlIllIIIIlI said: I usually feel bad about posting my code because... We really don't care about it, just post something we can run, it will save us time and you get a chance to have more support. Still having no issue with WinActivate although I get a large blink with Restore. “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
Solution pixelsearch Posted August 3, 2024 Solution Posted August 3, 2024 (edited) I wasn't talking about GUISetState() you don't need it at all. What you need is to indicate $hGUI as the last parameter of the functions you indicated in the title of your thread : Msgbox(... , $hGUI) ; last parameter FileOpenDialog(... , $hGUI) ; last parameter This is the easiest way to stop the interaction between "these gui pop-up" (as you named them) and the main GUI. For example with your code : Opt('GUIOnEventMode', 1) Global $gui = GUICreate('Example', 350,350) GUISetFont(10) guictrlcreatelabel('Video list',10,10, 100, 20) GUICtrlCreateList('', 10, 30, 330, 100) GUICtrlCreateButton('Add videos', 10, 120, 330, 25) GUICtrlSetOnEvent(-1, "Add") GUISetOnEvent(-3, 'Close') GUISetState() func Add() FileOpenDialog('Open video ...', @ScriptDir, 'Videos (*.mkv;*.mp4)', 0x7, "", $gui) endfunc while 1 sleep(1000) wend func Close() exit endfunc Isn't it what you wanted to achieve ? Edited August 3, 2024 by pixelsearch
lIlIIlIllIIIIlI Posted August 3, 2024 Author Posted August 3, 2024 1 hour ago, pixelsearch said: I wasn't talking about GUISetState() you don't need it at all. What you need is to indicate $hGUI as the last parameter of the functions you indicated in the title of your thread : Msgbox(... , $hGUI) ; last parameter FileOpenDialog(... , $hGUI) ; last parameter This is the easiest way to stop the interaction between "these gui pop-up" (as you named them) and the main GUI. For example with your code : Opt('GUIOnEventMode', 1) Global $gui = GUICreate('Example', 350,350) GUISetFont(10) guictrlcreatelabel('Video list',10,10, 100, 20) GUICtrlCreateList('', 10, 30, 330, 100) GUICtrlCreateButton('Add videos', 10, 120, 330, 25) GUICtrlSetOnEvent(-1, "Add") GUISetOnEvent(-3, 'Close') GUISetState() func Add() FileOpenDialog('Open video ...', @ScriptDir, 'Videos (*.mkv;*.mp4)', 0x7, "", $gui) endfunc while 1 sleep(1000) wend func Close() exit endfunc Isn't it what you wanted to achieve ? That's exactly what I was wanting, no need to manually disable/enable it now also. Thanks. What a strange explanation for that parameter though. I guess it is explained somewhere else that a child windows lock out the parent? Would be helpful to include an explanation or in the remark I think. Quote hwnd [optional] The window handle to use as the parent for this dialog.
pixelsearch Posted August 4, 2024 Posted August 4, 2024 Glad I could help IIRC it took me about 2 years to "discover" this behavior but since then I always use it when possible, to block the interaction between the owner window and the modal owned window. I think the help file should mention "owner" and not "parent" in the 4-5 topics related to this last $hWnd parameter.
pixelsearch Posted August 4, 2024 Posted August 4, 2024 For the record, I just retrieved a thread related to all this (starting with this post in the thread) where I discovered $MB_TASKMODAL for the 1st time, after an answer from @Melba23 Here is a part of what I answered him in the thread : Thanks Melba23 for this interesting link. I truly wish there was a link in the help file (MsgBox topic) leading us immediately to the Wiki page you indicated [...] So $MB_TASKMODAL would have done it for me... but well, as I use now this last parameter $hGUI in all others dialogue boxes (list below) then I guess I'll stick to it, though I'll try not to forget that $MB_TASKMODAL can do it too. Note : the 5 concerned dialogue boxes are : _ChooseColor() FileOpenDialog() FileSaveDialog() Inputbox() Msgbox() Also, you can have a look at this wiki page (probably written by Melba23 too). If you run his very last script on the page, you'll get the following display, with 2 GUI's and a MsgBox : Now you easily understand what should be modified in the function below (found at the end of his script) to prevent clicking on 1 or 2 GUI's while the MsgBox is active : Func MessageBox($iIndex) MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) ; ORIGINAL LINE ; MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex, 0, $g_hGUI1) ; MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex, 0, $g_hGUI2) ; MsgBox($MB_TASKMODAL, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) EndFunc ;==>MessageBox
lIlIIlIllIIIIlI Posted August 4, 2024 Author Posted August 4, 2024 3 hours ago, pixelsearch said: For the record, I just retrieved a thread related to all this (starting with this post in the thread) where I discovered $MB_TASKMODAL for the 1st time, after an answer from @Melba23 Here is a part of what I answered him in the thread : Thanks Melba23 for this interesting link. I truly wish there was a link in the help file (MsgBox topic) leading us immediately to the Wiki page you indicated [...] So $MB_TASKMODAL would have done it for me... but well, as I use now this last parameter $hGUI in all others dialogue boxes (list below) then I guess I'll stick to it, though I'll try not to forget that $MB_TASKMODAL can do it too. Note : the 5 concerned dialogue boxes are : _ChooseColor() FileOpenDialog() FileSaveDialog() Inputbox() Msgbox() Also, you can have a look at this wiki page (probably written by Melba23 too). If you run his very last script on the page, you'll get the following display, with 2 GUI's and a MsgBox : Now you easily understand what should be modified in the function below (found at the end of his script) to prevent clicking on 1 or 2 GUI's while the MsgBox is active : Func MessageBox($iIndex) MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) ; ORIGINAL LINE ; MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex, 0, $g_hGUI1) ; MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex, 0, $g_hGUI2) ; MsgBox($MB_TASKMODAL, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) EndFunc ;==>MessageBox 2 GUIs is an absolute brain blast, for years now I have just been reusing the same block of code in my example above for creating a single GUI. To be honest I have never even imagined placing this 'gui creation block' inside a function, and having 2 guis active at once (not counting the built-in message box/file dialog/etc). I guess ultimately these FileOpen/messagebox are just that in the end, functions that create a specific type of gui, and there is nothing stopping you from making your own and calling it. I don't understand the example so I'll have to study it sometime, because it can be quite limiting relying on the default dialog guis for input, and also I tend to use tabs for this 'secondary gui' thing which is kind of ridiculous in hindsight now. Thanks again.
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