In Addition to the ToolTip Command, AutoHotkey Offers Other Useful—Although Less Flexible—Message Commands
In my last blog, I suggested several different ways to use the ToolTip command. This time I take a quick look at a couple of other methods for passing information to users. While less flexible than the many of the other informational techniques, the Menu, Tray, Tip command and the TrayTip command each serve a useful purpose:
- System Tray Icon ToolTip for adding information about individual running AutoHotkey scripts.
- Alternative TrayTip Command for brief Windows notices about script activity.
System Tray Icon ToolTip
The Menu, Tray, Tip command allows AutoHotkey to tailor the informational ToolTip which pops up when hovering the mouse cursor over an AutoHotkey System Tray icon. One of the first uses I made of the Menu, Tray, Tip command labeled each instance of an InstantHotkeys.ahk System Tray icon with its Hotkey combination and insertion text (as shown in the image). Adding this reminder gave me both which Hotkey to use and the result:
Menu, Tray, Tip, %KeyCombo% %TextInsert%
I discuss this script in detail in Chapter Four, “An AutoHotkey App for Temporary Hotkeys (HotKey GUI Control)” of AutoHotkey Applications: Ideas and Tips for Writing Practical AutoHotkey Scripts.
Later in Chapter 12.1 “Instant Hotkey GUI and Menu Section” of the book Jack’s Motley Assortment of AutoHotkey Tips, I combined multiple InstantHotkeys into one script and transformed the Menu ToolTip into instructions for creating and viewing all the Hotkeys. In this version of the script, I converted the System Tray Icon into a one-click button for creating a new InstantHotkey. The right-click menu displays all active InstantHotkeys.
While limited to the current running AutoHotkey script’s System Tray icon, the ToolTip offers a convenient method for differentiating running scripts and passing user instructions.
Alternative TrayTip Command
The TrayTip Command uses the build-in balloon message window (toast notification in Windows 10) near the tray icon—displayed for five seconds when particular Windows or program activities occur. The TrayTip command does not offer much control over its operation (the Seconds parameter has no effect on Windows Vista and later) but it comes in handy for issuing quick temporary notifications with only one line of code.
For example, in Chapter 8.1.6, “Quick Fix for Inserting Color Data into the Windows Paint Palette” of the book AutoHotkey Applications: Ideas and Tips for Writing Practical AutoHotkey Scripts , the “Using the TrayTip Command for Displaying User Information” section replaces three lines of ToolTip command code in the Always-on-Top.ahk Hotkey routine with one TrayTip command (now including the added WinGetTitle command):
^#F8:: WinSet, AlwaysOnTop, toggle, A WinGet, ExStyle, ExStyle, A WinGetTitle, WinTitle , A TrayTip, %WinTitle% , % ExStyle & 0x8 ? "Always-On-Top ON" : "Always-On-Top OFF" Return
(The above snippet: uses line continuation techniques to wrap the one line of TrayTip code for display purposes.)
Originally, I only used the lone TrayTip command, but I recently added the WinGetTitle command to take advantage of the notice window’s Title parameter.
While a TrayTip only appears for a brief (unchangeable) period of time, it can offer the user positive affirmation whenever activating a Hotkey.
Click the Follow button at the top of the sidebar on the right of this page for e-mail notification of new blogs. (If you’re reading this on a tablet or your phone, then you must scroll all the way to the end of the blog—pass any comments—to find the Follow button.)
This post was proofread by Grammarly
(Any other mistakes are all mine.)
(Full disclosure: If you sign up for a free Grammarly account, I get 20¢. I use the spelling/grammar checking service all the time, but, then again, I write a lot more than most people. I recommend Grammarly because it works and it’s free.)
Find my AutoHotkey books at ComputorEdge E-Books!
Find quick-start AutoHotkey classes at “Robotic Desktop Automation with AutoHotkey“!