0

I have some hotkeys in a script with a custom tray icon.

Menu Tray, Icon, my_hotkeys.ico

One of them shows a message box with an OK button and question mark icon.

MsgBox, 32, My Hotkeys, Hey, here's some info...

But, it has the default green H AutoHotkey image in the Windows taskbar. I've looked through all the Menu options. And the GUI command claims that it uses the Menu icon, if set. But I can't find anything specific to MsgBox. Is there any way to change the MsgBox icon to the same custom icon that I'm using in the system tray?

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188

1 Answers1

4

There are several possible solutions:

  • Create and show a Gui with +OwnDialogs before calling MsgBox.
  • Code your own MsgBox look-alike using the Gui commands.
  • Compile your script (convert to exe) with a custom icon.
  • Replace the icon resources in AutoHotkey.exe (affecting all scripts).
  • Set a timer before showing the MsgBox, then send WM_SETICON after it appears.
  • Hook creation of the MsgBox window to set the icon before the window is shown - example in C++.

+OwnDialogs example:

Menu Tray, Icon, shell32.dll, 5  ; Folder icon
Gui +OwnDialogs
Gui Show           ; Since it has zero dimensions, it should be invisible.
MsgBox Testing...
ExitApp
Community
  • 1
  • 1
Lexikos
  • 987
  • 6
  • 16
  • Awesome answer, thanks! But, I won't be able to try any right away. Hold tight for results. It's kind of surprising that it's possible with regular windows and hard for message boxes, is that due to some underlying Windows problem? – Anthony Mastrean Nov 05 '12 at 18:23
  • The core of MsgBox is just a Win32 MessageBox() call. It accepts four parameters: hWnd (owner window), text, caption and type (MsgBox's Options parameter). There is no way to specify an icon, and when you call the function, you relinquish control; i.e. you need to use workarounds like posting a message, hooking window messages, or setting a timer to actually do anything while the dialog is visible. – Lexikos Nov 10 '12 at 07:08