Jump to content

No custom GUI icon in taskbar when au3 script is executed by "Run script" option


Go to solution Solved by argumentum,

Recommended Posts

Posted

What I noticed is

that if I run two or three scripts with _WinAPI_SetCurrentProcessExplicitAppUserModelID("My Custom GUI_v1.0")
the icons are grouped in the taskbar


while if I run them with _WinAPI_SetCurrentProcessExplicitAppUserModelID(StringTrimRight(@ScriptName, 3) & "_v1.0")
each one has its own icon


Thank you very much  :)

I know that I know nothing

Posted (edited)
11 minutes ago, ioa747 said:

What I noticed is ..

no, that would happen if using   _WinAPI_SetCurrentProcessExplicitAppUserModelID(_WinAPI_CreateGUID())   because the identifier would be unique in each run :) 

I edited the example script to show that too. Thanks.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

I made 4 scripts


H1.au3,  H2.au3 , H3.au3,  H4.au3  all 4 with

_WinAPI_SetCurrentProcessExplicitAppUserModelID(StringTrimRight(@ScriptName, 3) & "_v1.0")

Untitled-2.png

 

 

H1.au3,  H2.au3 , H3.au3,  H4.au3  all 4 with

_WinAPI_SetCurrentProcessExplicitAppUserModelID("My Custom GUI_v1.0")

Untitled-1.png

 

I know that I know nothing

Posted
27 minutes ago, ioa747 said:

I made 4 scripts: H1.au3,  H2.au3 , H3.au3,  H4.au3  all 4 with

obviously they are "H1_v1", "H2_v1", etc., because the ModelID string is different. I thought it was the same script run multiple times.

2 minutes ago, ioa747 said:

in windows10 with @ScriptFullPath it doesn't work as expected

Interesting. As far as I know, as long as the ModelID string is the same, ... that's that. It should be the same. Win 10 or 11.
Tho I never tested how long the string can be :think:   ( https://github.com/dotnet/maui/issues/20031 )

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

you are absolutely right, I copied it from
D:\i\Pro\.AutoIT\_Test\000_forum-topic\209641-No-custom-GUI-icon-in-taskbar-when-au3-script-is-executed-by-Run-script-option\1539207-argumentum.au3
to
D:\tmp\1539207-argumentum.au3
and it works

thanks

I know that I know nothing

Posted (edited)

https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_GetCurrentProcessExplicitAppUserModelID.htm

#NoTrayIcon
#include <GUIConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIProc.au3>

;~ _WinAPI_SetCurrentProcessExplicitAppUserModelID(_WinAPI_CreateGUID())
_WinAPI_SetCurrentProcessExplicitAppUserModelID(StringTrimRight(@ScriptName, 3) & "_v1.0")
;~ _WinAPI_SetCurrentProcessExplicitAppUserModelID("My Custom GUI_v1.0")

GUICreate("My Custom GUI", 300, 200, @DesktopWidth * 0.2, @DesktopHeight * 0.6)
GUISetIcon(@ScriptDir & '\iH1.ico') ; ok
TraySetIcon(@ScriptDir & '\iH1.ico') ; ok
GUISetState(@SW_SHOW)

Local $sAppID = _WinAPI_GetCurrentProcessExplicitAppUserModelID()

If @error Then
    MsgBox($MB_ICONERROR, "Error", "Failed to retrieve AppUserModelID. Error code: " & @extended)
Else
    MsgBox($MB_ICONINFORMATION, "AppUserModelID", "The current process AppUserModelID is: " & $sAppID)
EndIf


Do
Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE (-3)

 

Edited by ioa747

I know that I know nothing

Posted (edited)
22 minutes ago, ioa747 said:

you are absolutely right,

I figured after you posted that the length would be limited.
Found that the max length is 128 :)
So bad idea on my part. but could use a hash of the @ScriptFullPath to make it unique for the path 🤔 

Edited by argumentum
oops

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)
29 minutes ago, ioa747 said:

then the max length is 127. Because after that it returns an error and an empty string 

Edit: I added these findings to the example.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

then it's better with StringTrimRight(@ScriptName, 4)   to eat the dot too

"MyScript_v1.0" in stat "MyScript._v1.0"  :think:

Edited by ioa747

I know that I know nothing

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...