MsgBox modal not working as I need

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arathra
Posts: 23
Joined: 29 Aug 2016, 06:22

MsgBox modal not working as I need

04 Oct 2016, 07:38

Not sure if I'm doing this right, but I have a MsgBox which I'd like modal so that it is impossible to do anything until the OK button has been clicked or the MsgBox times out.

This is my current code:

Code: Select all

MsgBox, 4144, Found!, Excited Message, 5
The box remains on top but I'm still able to click the window underneath it and so on. I've also tried with options set to 8192 and 262144.

What I want is for this MsgBox to appear and prevent any other interaction on the computer until either the 5 seconds pass and it disappears or I click the OK button.

Is this possible?

Thanks for your help!
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: MsgBox modal not working as I need

04 Oct 2016, 07:59

e.g. with a 2nd (child) gui instand of a msgbox
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
Grendahl
Posts: 170
Joined: 30 Sep 2013, 08:21

Re: MsgBox modal not working as I need

04 Oct 2016, 08:03

From MSDDN: https://msdn.microsoft.com/en-us/librar ... s.85).aspx

App modal:
The user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other threads and work in those windows.
Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but pop-up windows are not.

System Modal:
Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd.

Task Modal:
Same as MB_APPLMODAL except that all the top-level windows belonging to the current thread are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the calling thread without suspending other threads.

Since Autohotkey is an interpreted language, and depends on Windows functionality in the background, and since from what I can tell, Windows message boxes do not block other input or threads from running or being interacted with... you've got to be more creative with your solution.

Perhaps begin by looking into https://autohotkey.com/docs/commands/BlockInput.htm.
arathra
Posts: 23
Joined: 29 Aug 2016, 06:22

Re: MsgBox modal not working as I need

06 Oct 2016, 04:51

Thanks for that. BlockInput looks interesting so yes, I'll play around with that a bit - and I can already see myself getting locked out of the computer :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 313 guests