Page 1 of 1

Icons and program

Posted: 12 Jul 2017, 10:45
by Albireo
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?

Re: Icons and program

Posted: 12 Jul 2017, 13:30
by Guest
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.

Re: Icons and program

Posted: 12 Jul 2017, 15:01
by Albireo
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.

Re: Icons and program

Posted: 12 Jul 2017, 15:12
by Guest
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

Re: Icons and program

Posted: 12 Jul 2017, 16:06
by Albireo
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.

Re: Icons and program

Posted: 12 Jul 2017, 16:38
by Guest
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:

Re: Icons and program

Posted: 13 Jul 2017, 10:05
by Albireo
With the solution from "SKAN" above, does not affect the icon on the taskbar.

Re: Icons and program

Posted: 13 Jul 2017, 20:33
by jeeswg
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

Re: Icons and program

Posted: 17 Jul 2017, 05:26
by Albireo
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"