Jump to content

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


maniootek
 Share

Go to solution Solved by argumentum,

Recommended Posts

According to this my old post with similar problem: different title on taskbar/gui

 

here is modification for different icon on taskbar/gui -> which works for me in all situations (Drag/Run/Scite...):

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>
#include <SendMessage.au3>

;~ Global Const $WM_SYSCOMMAND = 0x0112
;~ Global Const $SC_MINIMIZE = 0xF020
;~ Global Const $SC_RESTORE = 0xF120
;~ Global Const $WM_MOVE = 0x3
;~ Global Const $WM_SIZE = 0x05

$app = GUICreate("Application title", 1, 1,-1,-1,$WS_POPUP)
GUISetIcon(@ScriptDir & '\test1.ico')
GUISetState(@SW_SHOW, $app)
$gui = GUICreate("Form title", 300, 200, -1, -1, -1, -1, $app)
GUISetIcon(@ScriptDir & '\test2.ico')
GUISetState(@SW_SHOW, $gui)

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
GUIRegisterMsg($WM_MOVE, "WM_MOVE")

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Switch $wParam
        Case $SC_MINIMIZE
            _SendMessage($app, $WM_SYSCOMMAND, $SC_MINIMIZE, 0)
            GUISetState(@SW_HIDE, $gui)
            Return 0
        Case $SC_RESTORE
            _SendMessage($app, $WM_SYSCOMMAND, $SC_RESTORE, 0)
            GUISetState(@SW_SHOW, $gui)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
;~  If $hWnd = $gui Then
        $pos = WinGetPos($gui)
        WinMove($app, '', $pos[0], $pos[1])
;~      WinMove($app, '', _LoWord($wParam), _HiWord($wParam))
;~  EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc

 

Edited by Zedna
Link to comment
Share on other sites

Here is simplified version, which should work also on new AutoIt's versions (I use very old 3.2.12.1):

#NoTrayIcon
#include <GUIConstantsEx.au3>

$app = GUICreate("Application title", 1, 1,-1,-1,0x80000000) ; $WS_POPUP=0x80000000
GUISetIcon(@ScriptDir & '\test1.ico')
GUISetState(@SW_SHOW, $app)
$gui = GUICreate("Form title", 300, 200, -1, -1, -1, -1, $app)
GUISetIcon(@ScriptDir & '\test2.ico')
GUISetState(@SW_SHOW, $gui)

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

 

But this works for me also when running on my (Unzipped) AutoIt 3.3.14.5/3.3.16.1 ...

Edited by Zedna
Link to comment
Share on other sites

@Nine can you enlighten us ?

I have this version
v3.3.16.1    19 September, 2022
https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.zip

if i run the script from shell with right click custom icon in taskbar not working
if i run the script from SciTE with f5 custom icon in taskbar not working
if i drop the script on C:\Program Files (x86)\AutoIt3\AutoIt3.exe custom icon in taskbar not working

if I copy  the AutoIt3 folder from C:\Program Files (x86)\AutoIt3  to C:\ , and  drop the script on AutoIt3.exe custom icon in taskbar is working

Is there a logical explanation?

I know that I know nothing

Link to comment
Share on other sites

I have got standard instalation by installer 3.2.12.1 + full Scite4AutoIt3 (from that old time).

Newer versions on my computer are only unzipped AutoIt+Scite4AutoIt3.

On my machine it's OK with ALL versions in all scenarios.

I still don't know why it's OK on my machine and not on yours.

EDIT:

I have (completely) disabled UAC on all my computers, maybe try to disable it (temporarily) too ...

Edited by Zedna
Link to comment
Share on other sites

Well, I have both too. And none is working correctly as you.  In fact, you are the only one that works.  So what does it tell you ? You are an MVP, question and answer is on your side to understand and tell us the reason.

Link to comment
Share on other sites

On my Windows 10 system with AutoIt 3.3.16.1 installed, if I have the system taskbar setting 'Combine taskbar buttons' set to 'Always, hide labels', I get the generic AutoIt icon in the taskbar when running an uncompiled script. But if I change that setting to 'Never' or 'When taskbar is full', I see the custom icon.

image.png.b12d3e5905801229e8355930f9003118.png

 

image.png.07e1f162d308887db11bc2a458b241d0.png

Edited by TimRude
Link to comment
Share on other sites

that is something. But what cracks me up is

if I copy  the AutoIt3 folder from C:\Program Files (x86)\AutoIt3  to C:\ , and  drop the script on AutoIt3.exe custom icon in taskbar is working

Is there a logical explanation?

I have come to the conclusion that something is going on in the windows registry, but I don't know what  :)

I know that I know nothing

Link to comment
Share on other sites

24 minutes ago, argumentum said:

_WinAPI_SetCurrentProcessExplicitAppUserModelID() will fix that :)

Yep, it sure does! Now I get the custom icon in the taskbar no matter what 'Combine taskbar buttons' setting I use.

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

_WinAPI_SetCurrentProcessExplicitAppUserModelID(_WinAPI_CreateGUID()) ; ensure a unique ID

GUICreate("My Custom GUI", 300, 200)
GUISetIcon(@SystemDir & "\shell32.dll", 239)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

Edited by TimRude
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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