TaskDialog() - the other 'MsgBox' for Win Vista+

Post your working scripts, libraries and tools
just me
Posts: 4286
Joined: 02 Oct 2013, 08:51
Location: Germany

TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 02:34

MSDN wrote:Task Dialog
... A task dialog is similar to, while much more flexible than, a basic message box.
Source

The task dialog was introduced with Win Vista and the simple form TaskDialog() can be used as a 'modernized' message box replacement.

There are at least two implementations at AutoHotkey dot com:
  • TheGood's 'all-inclusive' solution wrapping the TaskDialogIndirect() function:
    :arrow: /board/topic/54555-taskdialog-stdlib-compatible/
  • nepter's solution providing wrapper functions for both TaskDialog() and TaskDialogIndirect() functions:
    :arrow: /board/topic/96587-ahk-l-taskdialog-taskdialogex-windows-vista/

Nevertheless, I think it's worth to be found here too (though according to Microsoft it won't work on Win XP). So I wrote a slightly changed wrapper for the TaskDialog() function using the main instruction as the only mandatory parameter and additional undocumented icon values found in TheGood's script.

Screenshot:
TaskDialog.PNG
TaskDialog.PNG (5.86 KiB) Viewed 3719 times

Simple version

Advanced version

Updated on 2014-09-26: see Advanced version
Last edited by just me on 26 Sep 2014, 00:48, edited 4 times in total.
Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 02:45

Cool! Thanks just me
ozzii
Posts: 277
Joined: 30 Oct 2013, 06:04

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 03:28

Yes, this is cool.
If I may:
Maybe a "simpler" way to do the combination of the button. Calculating in HEX is not my strong side ;)
guest3456
Posts: 1974
Joined: 09 Oct 2013, 10:31

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 03:35

ozzii wrote:If I may:
Maybe a "simpler" way to do the combination of the button. Calculating in HEX is not my strong side ;)


You may not, because its already been done. Read the docs:

just me wrote:

Code: [Select all] [Expand] [Download] (TaskDialog.ahk)GeSHi © Codebox Plus


Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 03:45

@ozzii
TaskDialog() inline doc wrote:This parameter may be a combination of the integer keys defined in TDBTNS or a pipe (|) separated list of the string keys.
just me
Posts: 4286
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 04:17

ozzii, I've updated the script using decimal values. But you don't need to precalculate at all. You just might use TaskDialog("My Main", "My Extra", "My Title", 0x02 + 0x04).
Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 04:37

Hi just me, if it's OK with you, perhaps you can provide more flexibility on the type of delimiter for the Buttons parameter other than a pipe(|). Something like StrSplit(Buttons, ["|", " ", ",", "`n"])
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 06:18

so cool.thanks.
how can i set this beautiful msgbox alway on top?
and where is the close button?
QQ截图20140920230307.jpg
QQ截图20140920230307.jpg (54.33 KiB) Viewed 3642 times
User avatar
DataLife
Posts: 174
Joined: 29 Sep 2013, 19:52

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 11:14

TaskDialog() has 3 of the 4 icons supported by Msgbox, it is missing the Icon Question.

Is it possible to have question mark icon?
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 11:24

@DataLife, it only supports the following:

Code: [Select all] [Download] GeSHi © Codebox Plus

TD_ERROR_ICON       -> A stop-sign icon appears in the task dialog.
TD_INFORMATION_ICON -> An icon consisting of a lowercase letter i in a circle appears in the task dialog.
TD_SHIELD_ICON -> A security shield icon appears in the task dialog.
TD_WARNING_ICON -> An exclamation-point icon appears in the task dialog.
User avatar
joedf
Posts: 5414
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 17:47

Very interesting, I'll check it out!
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

20 Sep 2014, 19:41

Could you set 2 extra parameters for " timeout" and "alway on top"?
just me
Posts: 4286
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

21 Sep 2014, 02:01

Coco wrote:...perhaps you can provide more flexibility on the type of delimiter for the Buttons parameter other than a pipe(|). Something like StrSplit(Buttons, ["|", " ", ",", "`n"])
Sure, I'll use your StrSplit for the next update.
huyaowen wrote:and where is the close button?
The close button only appears in combination with the cancel button.
DataLife wrote:TaskDialog() has 3 of the 4 icons supported by Msgbox, it is missing the Icon Question.
This has been discussed on MSDN too. It seems that the lack of the question mark is intended by Microsoft due to changed user interface design guidelines.
huyaowen wrote:Could you set 2 extra parameters for " timeout" and "alway on top"?
The task dialog doesn't offer equivalent options. But I'll think about a workaround.
Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.
ozzii
Posts: 277
Joined: 30 Oct 2013, 06:04

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

21 Sep 2014, 03:09

guest3456 wrote:You may not, because its already been done. Read the docs:


I overlooked this and didn't understand it well at my first read.
So, just me, I am so sorry for having overlooked your documentation :headwall:

Oh, and thanks, for the update.
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

21 Sep 2014, 03:44

thanks.
waiting for the update.
just me
Posts: 4286
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

22 Sep 2014, 06:06

Well, it's done. I've implemented the requested features, but decided to keep the original function as 'simple version' and to release a second 'advanced version'. The 'advanced' features are:

  • AlwayOnTop option.
  • Support for the missing question mark icon.
  • Support for custom icons.
  • New Timeout parameter.

I hope you'll like it.
Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

22 Sep 2014, 07:14

thank you very much.
Could u also import the normal msgbox for XP?
then display the beautiful msgbox on win7 or newer.and display a normal msgbox on WINXP.
just me
Posts: 4286
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

22 Sep 2014, 07:29

I think I can! ;)
Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

22 Sep 2014, 07:57

aha!so amazing!
thanks again.
Could the normal msgbox recognize the parameters(on top,icon,timeout and so on)?
Last edited by huyaowen on 22 Sep 2014, 18:18, edited 1 time in total.
User avatar
jNizM
Posts: 2118
Joined: 30 Sep 2013, 01:33
GitHub: jNizM

Re: TaskDialog() - the other 'MsgBox' for Win Vista+

22 Sep 2014, 08:32

@huyaowen:
some info for you about MsgBox
- MessageBox function
- MessageBoxEx function
- MessageBoxIndirect function & MSGBOXPARAMS structure

@just me:
something to add for Task Dialogs
About Task Dialogs (Parts of a Task Dialog)
[AHK] 1.1.25.02 x64 Unicode
[WIN] 10 Pro (Version 1607 | Build 14393.1198) x64
My GitHub Profile | Donations are appreciated if I could help you

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 6 guests