Cannot change tray icon when starting script using Task Scheduler Topic is solved

Report problems with documented functionality
000
Posts: 11
Joined: 20 May 2018, 16:51

Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 27 Jul 2020, 12:18

Code: Select all

f1::
menu, tray, icon, imageres.dll
return
Also tried using hotkey command
Task Scheduler trigger is at log on

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: Cannot change tray icon when starting script using Task Scheduler

Post by boiler » 27 Jul 2020, 13:10

Do you mean it doesn’t change until you press the hotkey and you want it to change on its own without you having to press anything?

000
Posts: 11
Joined: 20 May 2018, 16:51

Re: Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 27 Jul 2020, 13:32

it won't work when i press the hotkey

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 27 Jul 2020, 13:37

Tested here in W10 v1909 64-bit with AHK 1.1.33.02 U64 — works perfectly, i.e., when I press F1, it changes the tray icon from the AHK one to the imageres one. If you want it to change before hitting F1, move the menu,tray line above the f1:: line. Of course, for this to make any sense, you must have some code in the f1:: path. Regards, Joe

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 27 Jul 2020, 13:40

Oh, one other thought...maybe F1, which is the Windows standard for the Help key, is being caught by the program that is running when you hit it. Try Alt+Ctrl+F1 to test that theory, i.e., change f1:: to !^f1::. Now does it work when you press Alt+Ctrl+F1?

000
Posts: 11
Joined: 20 May 2018, 16:51

Re: Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 27 Jul 2020, 14:12

thanks for looking into it. did you use Task Scheduler, logged out and back in, then try the hotkey? that's when it doesn't work. F1 is just random

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 27 Jul 2020, 14:29

I created a task in Task Scheduler with this Action:

"C:\Program Files\AutoHotkey\AutoHotkeyU64.exe" c:\temp\TestTaskScheduler.ahk

I did not set a Trigger for it...just ran it manually. I do not want to log out and back in to test that aspect of it,..and I'm doubtful that that's the issue. Are you saying that it works when you run it manually from Task Scheduler and does not work when you run it via an "At log on" Trigger?

000
Posts: 11
Joined: 20 May 2018, 16:51

Re: Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 27 Jul 2020, 22:30

yes it works when i run it manually but not automatically at logon

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 27 Jul 2020, 22:57

000 wrote:not automatically at logon
Which one is it:
(1) The script runs at log on, i.e., it appears in the system tray, but the hotkey does not work.
(2) The script doesn't even run at log on.

In the General tab, is "Run with highest privileges" ticked? If not, try that.

What are the details of the Action, i.e., the program/script and the argument?

000
Posts: 11
Joined: 20 May 2018, 16:51

Re: Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 28 Jul 2020, 10:35

the script runs at logon but the hotkey does not work. i tried with highest privileges
Program/script: "C:\Program Files\AutoHotkey\AutoHotkeyU64.exe"
Add arguments (optional): C:\Users\user\Desktop\test.ahk

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 28 Jul 2020, 11:39

000 wrote:
28 Jul 2020, 10:35
the script runs at logon but the hotkey does not work. i tried with highest privileges Program/script: "C:\Program Files\AutoHotkey\AutoHotkeyU64.exe" Add arguments (optional): C:\Users\user\Desktop\test.ahk
All of that looks good. As I mentioned earlier, it works perfectly here via the Task Scheduler in v1909, although I did not test it with an "At log on" Trigger. However, I just tested it in a v2004 sandbox with an "At log on" Trigger and was able to confirm your result...it works when run manually but does not work with the "At log on" Trigger. It even works after doing a "Reload This Script" via the context menu. This led me to a theory: Something in the logging on process is clearing hotkey assignments after the script has run. To test the theory, I put in a "Delay task for 30 seconds" in the Advanced Settings of the Trigger...WORKED! Regards, Joe

000
Posts: 11
Joined: 20 May 2018, 16:51

Re: Cannot change tray icon when starting script using Task Scheduler

Post by 000 » 29 Jul 2020, 11:21

AMAZING! thank you!! it even works when you delay it for just 1 second

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 29 Jul 2020, 12:40

000 wrote:it even works when you delay it for just 1 second
Interesting! Thanks for letting me know that. Regards, Joe

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: Cannot change tray icon when starting script using Task Scheduler

Post by lexikos » 29 Jul 2020, 23:10

Perhaps the system tray doesn't actually exist at the moment the logon event is raised.

In any case, I see no way that this could be a bug in AutoHotkey.

User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Cannot change tray icon when starting script using Task Scheduler

Post by JoeWinograd » 29 Jul 2020, 23:34

lexikos wrote:Perhaps the system tray doesn't actually exist at the moment the logon event is raised.
Fascinating theory...sounds very plausible.
lexikos wrote:In any case, I see no way that this could be a bug in AutoHotkey.
Agreed!

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: Cannot change tray icon when starting script using Task Scheduler  Topic is solved

Post by lexikos » 21 Apr 2021, 03:09

There was a bug where the tray icon could not be changed or removed after the program receives a "TaskbarCreated" message when the tray icon (and taskbar) already existed. This message is (now) known to be sent when the DPI changes on Windows 10, but I guess it's also sent while you are logging on. Perhaps your script was launching after the taskbar was created but before the message was broadcast, so when the message was received, the tray icon already existed. By delaying your script for a moment, it probably avoided the "TaskbarCreated" message.

Anyway, that bug was fixed in v1.1.33.07.

Post Reply

Return to “Bug Reports”