Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

How To Change The Tray Icon


  • Please log in to reply
9 replies to this topic
GWODIN
  • Guests
  • Last active:
  • Joined: --
I was wondering how to change the tray icon at the bottom i have tried
Menu,Filename.ico,,1
but that doesn't seem to work for me, i always get a message that says "menu requires that pram #2 be non-blank" I have looked at the menu command and it didn't help me. I need some help with this so please post something to help.

Thanks!

  • Guests
  • Last active:
  • Joined: --
Menu, Tray, Icon, Filename.ico

GWODIN
  • Guests
  • Last active:
  • Joined: --
Thanks

GWODIN
  • Guests
  • Last active:
  • Joined: --
Now I'm Having Trouble making it a different icon when you pause it. How do you do that?

silveredge78
  • Members
  • 499 posts
  • Last active: Mar 14 2014 03:19 AM
  • Joined: 25 Jul 2006

Change the Tray Icon or ToolTip (MenuName must be TRAY)
Icon [, FileName, IconNumber, 1]: Changes the script's icon to one of the ones from FileName. The following types of files are supported: ICO, CUR, ANI, EXE, DLL, CPL, SCR, and other types that contain icon resources. To use an icon group other than the first one in the file, specify its number for IconNumber (if omitted, it defaults to 1). For example, 2 would load the default icon from the second icon group. Specify an asterisk (*) for FileName to restore the script to its default icon.

The last parameter: Specify 1 for the last parameter to freeze the icon, or 0 to unfreeze it (or leave it blank to keep the frozen/unfrozen state unchanged). When the icon has been frozen, Pause and Suspend will not change it. Note: To freeze the current icon, use Menu, Tray, Icon,,, 1 ; (or 0 to unfreeze)

Changing the tray icon also changes the icon displayed by InputBox, Progress, and subsequently-created GUI windows. Compiled scripts are also affected even if a custom icon was specified at the time of compiling. Note: Changing the icon will not unhide the tray icon if it was previously hidden by means such as #NoTrayIcon; to do that, use Menu, Tray, Icon (with no parameters).

Slight distortion may occur when loading tray icons from file types other than .ICO. This is especially true for 16x16 icons. To prevent this, store the desired tray icon inside a .ICO file.

There are some icons built into the operating system's DLLs and CPLs that might be useful. For example: Menu, Tray, Icon, Shell32.dll, 174 ; Omits the DLL's path so that it works on Windows 9x too.

The built-in variables A_IconNumber and A_IconFile contain the number and name (with full path) of the current icon (both are blank if the icon is the default).

Icon (with no parameters): Creates the tray icon if it isn't already present. This will override #NoTrayIcon if that directive is also present in the script.

NoIcon: Removes the tray icon if it exists. If this command is used at the very top of the script, the tray icon might be briefly visible when the script is launched. To prevent that, use #NoTrayIcon instead. The built-in variable A_IconHidden contains 1 if the tray icon is currently hidden or 0 otherwise.

Tip [, Text]: Changes the tray icon's tooltip -- which is displayed when the mouse hovers over it. To create a multi-line tooltip, use the linefeed character (`n) in between each line, e.g. Line1`nLine2. Only the first 127 characters of Text are displayed. If Text is omitted, the tooltip is restored to its default text. The built-in variable A_IconTip contains the current text of the tooltip (blank if the text is at its default).


SilverEdge78

GWODIN
  • Guests
  • Last active:
  • Joined: --
i read that, but its so confusing could someone just give me an example please?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
The relevant part is:

The last parameter: Specify 1 for the last parameter to freeze the icon, or 0 to unfreeze it (or leave it blank to keep the frozen/unfrozen state unchanged). When the icon has been frozen, Pause and Suspend will not change it. Note: To freeze the current icon, use Menu, Tray, Icon,,, 1 ; (or 0 to unfreeze)

...but you also need to be able to detect when the script is paused/suspended.
; Call WM_COMMAND() whenever the WM_COMMAND (0x111) message is received.
OnMessage(0x111, "WM_COMMAND")

;...

WM_COMMAND(wParam, lParam)
{
    static IsPaused, IsSuspended
    Critical
    SetFormat, Integer, D ; to be sure (since if..in compares alphabetically)
    id := wParam & 0xFFFF
    if id in 65305,65404,65306,65403
    {  ; "Suspend Hotkeys" or "Pause Script"
        if id in 65306,65403  ; pause
            IsPaused := ! IsPaused
        else  ; at this point, A_IsSuspended has not yet been toggled.
            IsSuspended := ! A_IsSuspended

        ; INSERT CODE HERE to set icon based on IsPaused and/or IsSuspended
    }
}
Note: IsPaused will go out of sync if the "Pause" command is used from script, unless you also call WM_COMMAND(65306,0).

Update (July 15, 2009): As of v1.0.48, you may use the built-in variable A_IsPaused.

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
TBH I don't both just for scripts
I would normally just use an icon when compiling to *.exe

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
That reminds me; you can replace all icons in a compiled script using ResHacker. That way you don't need to write any script. I think someone even wrote a GUI to automate it.

quatermass
  • Members
  • 220 posts
  • Last active: Dec 16 2013 09:00 PM
  • Joined: 14 Dec 2005

That reminds me; you can replace all icons in a compiled script using ResHacker. That way you don't need to write any script. I think someone even wrote a GUI to automate it.



Some of us are still waiting for this to be added as standard in AHK....

:D

A line of text in the script that tells the compiler what to do seems like the way to go. 8)
Stuart Halliday