Strange MessageBox Behavior

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Strange MessageBox Behavior

02 Feb 2020, 04:40

hello, I was wondering why the "esc" hotkey works in this script:

Code: Select all

1::
MsgBox, 5, MyMsgBox, Hello
Return

esc::
WinClose, MyMsgBox
Return
..but it does *not* work in this one:

Code: Select all

1::
MsgBox, 4, MyMsgBox, Hello
Return

esc::
WinClose, MyMsgBox
Return
gregster
Posts: 9067
Joined: 30 Sep 2013, 06:48

Re: Strange MessageBox Behavior

02 Feb 2020, 05:25

In the case with the 4 option, the x (the Close button in the msgbox's titlebar) is disabled by the Windows system, and there is no Cancel button ("clicking the X is the same as pressing Cancel").

If there is no Cancel button, it can't be cancelled and WinClose, which just sends a WM_CLOSE message, can't override this requirement. The user is forced to choose yes or no.

Afaik, this is intentional and based on the behaviour of the underlying MessageBox function of the Windows system.
scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Re: Strange MessageBox Behavior

03 Feb 2020, 10:18

yes, you're right - I hadn't noticed that the 'X' button is disabled on a MessageBox, 4.

That's odd, I wonder why it's like that - 4 cannot be closed, but 5 (and others) are able to be closed.

Oh well, thanks for clearing that up! I was scratching my head over that one on the weekend lol ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Rohwedder and 166 guests