MsgBox, InputBox, TrayTip
Posted: 14 Oct 2016, 18:10
I plan to make the following changes:
I think that using an output parameter is more natural than having a built-in variable just for this function's return value. The output parameter could be exclusive to command mode, but it's just as easy (same amount of code) to have it in both modes.
Most (but not all) commands/functions with return values put the OutputVar first and omit it in expression mode, but doing that for MsgBox would mean writing MsgBox,, quite often.
Options would be as it is now, or optionally a space-delimited list of more memorable string options. This is the part I'm not sure about - what string values to use. Currently I'm thinking this:They should be self-explanatory. I also considered contractions like y/n, possibly altering the return value in that case to allow brevity when comparing the result - i.e. MsgBox(Text,, "y/n") = "y" vs MsgBox(Text,, "YesNo") = "Yes". However, Cancel/Try Again/Continue throws a spanner in the works (two 'C's). 'C' for Cancel is obvious with OK/Cancel, but Windows actually underlines Continue. (There's no mnemonic for Cancel - it's tied to Escape.)
For the icons, I think a single character resembling the icon is more memorable and convenient than a word like Stop/Error/Hand. I considered not requiring "Icon", but x should be reserved for possible use positioning the MsgBox.
I think the other options are less frequently used and can stay as numbers. A string of options could also include numeric options, combined or individually (just as the Gui command allows style options).
InputBox and TrayTip would have consistent parameter ordering:
Text comes first, as Title is often omitted. TrayTip's Seconds parameter may be removed completely (since it only works on XP) or merged into Options as a string.
This also makes TrayTip consistent with ToolTip and fixes the problem of TrayTip Some text not actually showing a TrayTip (it should be TrayTip Title, Some text in v1).
- Remove MsgBox smart comma handling.
- Remove A_MsgBoxResult.
- Change MsgBox usage as below (and InputBox and TrayTip further below).
Code: Select all
MsgBox Text [, Title, Options, ByRef Result]
Result := MsgBox(Text [, Title, Options, ByRef Result])
Most (but not all) commands/functions with return values put the OutputVar first and omit it in expression mode, but doing that for MsgBox would mean writing MsgBox,, quite often.
Options would be as it is now, or optionally a space-delimited list of more memorable string options. This is the part I'm not sure about - what string values to use. Currently I'm thinking this:
Code: Select all
OKCancel
AbortRetryIgnore
YesNoCancel
YesNo
RetryCancel
CancelTryAgainContinue
Iconx
Icon?
Icon!
Iconi
For the icons, I think a single character resembling the icon is more memorable and convenient than a word like Stop/Error/Hand. I considered not requiring "Icon", but x should be reserved for possible use positioning the MsgBox.
I think the other options are less frequently used and can stay as numbers. A string of options could also include numeric options, combined or individually (just as the Gui command allows style options).
InputBox and TrayTip would have consistent parameter ordering:
Code: Select all
InputBox, OutputVar [, Text, Title, Options, Default]
TrayTip [, Text, Title, Options]
This also makes TrayTip consistent with ToolTip and fixes the problem of TrayTip Some text not actually showing a TrayTip (it should be TrayTip Title, Some text in v1).