Icons and program

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Icons and program

12 Jul 2017, 10:45

I have a script that starts a program.
Depending on the parameters the program starts with, the program performs different things.

Code: Select all

Run Program.exe .\info1.ini, s:\Program, Max, SquidPID
=> icon1

Code: Select all

Run Program.exe .\info2.ini, s:\Program, Max, SquidPID
=> icon2

At the bottom of the screen, I can see that the program has been started, but is it possible to control which icon is displayed?
i.e. If the program is started in one way, one icon appears in the bottom of the screen, and if the program is started in another way, another icon will appear.
Is it possible?
Guest

Re: Icons and program

12 Jul 2017, 13:30

Yes, look at https://autohotkey.com/docs/commands/Me ... st_be_TRAY you can change the tray icon as many times in a script as you like so after the run ini1 show trayicon1 after run ini2 show trayicon2 etc. Very easy.
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Icons and program

12 Jul 2017, 15:01

It is something i don't understand (or can not explain)
Nothing happens, when I use this command, for example

Code: Select all

Menu, Tray, Icon, C:\temp\test.ico
run % A_WinDIr . "\notepad.exe",,, SquidPID
Nothing happen with the icon on the bottom of the window.
Guest

Re: Icons and program

12 Jul 2017, 15:12

That is because your script exits immediately after the run command, I doubt very much you even see the icon as it is so fast to appear and go away. Try this, the msgbox will keep your script active

Code: Select all

Menu, Tray, Icon, C:\temp\test.ico
run % A_WinDIr . "\notepad.exe",,, SquidPID
MsgBox, Look at the tray icon now
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Icons and program

12 Jul 2017, 16:06

OK!
Yes! It handles the icon in the system tray, but not the icons at the bottom of the screen (as I wish)
(the original icon for notepad, is still there in the example above)

Now, the solution is to make a shortcut, and launch the program by starting the shortcut with AHK.
Guest

Re: Icons and program

12 Jul 2017, 16:38

So you want to change the icon of notepad.exe - that is not the icon of the script.

It should be possible, have a look here https://autohotkey.com/board/topic/1978 ... -a-window/ posts by SKAN (you can skip the "IfNotExist" command of course) - it works here on 64bit so should work everywhere given the age of the code example. :dance:
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Icons and program

13 Jul 2017, 10:05

With the solution from "SKAN" above, does not affect the icon on the taskbar.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Icons and program

13 Jul 2017, 20:33

Does this not work for you?

Code: Select all

q:: ;set Notepad icons to AutoHotkey icons (tested on Windows 7)
WinGet, hWnd, ID, ahk_class Notepad
hIcon := LoadPicture(A_AhkPath, "", vType)
SendMessage, 0x80, 0, % hIcon,, % "ahk_id " hWnd ;WM_SETICON ;sets title bar icon + taskbar icon
SendMessage, 0x80, 1, % hIcon,, % "ahk_id " hWnd ;WM_SETICON ;sets alt+tab icon
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Icons and program

17 Jul 2017, 05:26

jeeswg wrote:Does this not work for you?

Code: Select all

q:: ;set Notepad icons to AutoHotkey icons (tested on Windows 7)
WinGet, hWnd, ID, ahk_class Notepad
hIcon := LoadPicture(A_AhkPath, "", vType)
SendMessage, 0x80, 0, % hIcon,, % "ahk_id " hWnd ;WM_SETICON ;sets title bar icon + taskbar icon
SendMessage, 0x80, 1, % hIcon,, % "ahk_id " hWnd ;WM_SETICON ;sets alt+tab icon
return
Thanks!
Maybe it's something I do not understand, but nothing happens. (Windows 10)
1. Open Notepad
2. Run the AHK-program as administrator
3. Press the key "q"

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mamo691, MrDoge and 239 guests