Sign in to follow this  
Followers 0
LoWang

change icon of the running application

9 posts in this topic

Hello, I know I can change a window title by WinSetTitle, but is it somehow possible to also change icon of the window and in the taskbar? Changing the icon in the executable file via resource hacker or other tools unfortunatelly corrupted it so I want to do it runtime.

Share this post


Link to post
Share on other sites



GUISetIcon but youll need it to be a .ico I believe.

example...

$gui = GUICreate("Test",500,500,500,500)
            GuiSetIcon("Myicon.ico", 0)

Share this post


Link to post
Share on other sites

I want to change icon of any application. Not just my script I made, so this is not it I think...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Share this post


Link to post
Share on other sites

Hm that's bad. I hoped maybe somebody knows some hack :-] Maybe if my script runs the app process then it would have permissions to do this with it...?

Share this post


Link to post
Share on other sites

bump...

Share this post


Link to post
Share on other sites

This?

_GUISetIcon(WinGetHandle("[ACTIVE]", ""), "shell32.dll", 322) ; name, not ordinal value



Func _GUISetIcon($hGui, $sModule, $iName) ; for loaded modules in this shape

    Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "wstr", $sModule)

    Local $hModule = $a_hCall[0]

    $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _
            "hwnd", $hModule, _
            "int", $iName, _
            "dword", 1, _ ; IMAGE_ICON
            "int", 32, _
            "int", 32, _
            "dword", 0) ; LR_DEFAULTCOLOR

    Local $hIcon = $a_hCall[0]

    DllCall("user32.dll", "hwnd", "SendMessageW", _
            "hwnd", $hGui, _
            "dword", 0x0080, _ ; WM_SETICON
            "dword", 1, _ ; 1 = ICON_BIG, 0 = ICON_SMALL
            "ptr", $hIcon)

EndFunc   ;==>_GUISetIcon

That will change the SciTE icon if you are running scripts there.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

This?

_GUISetIcon(WinGetHandle("[ACTIVE]", ""), "shell32.dll", 322) ; name, not ordinal value



Func _GUISetIcon($hGui, $sModule, $iName) ; for loaded modules in this shape

    Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "wstr", $sModule)

    Local $hModule = $a_hCall[0]

    $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _
            "hwnd", $hModule, _
            "int", $iName, _
            "dword", 1, _ ; IMAGE_ICON
            "int", 32, _
            "int", 32, _
            "dword", 0) ; LR_DEFAULTCOLOR

    Local $hIcon = $a_hCall[0]

    DllCall("user32.dll", "hwnd", "SendMessageW", _
            "hwnd", $hGui, _
            "dword", 0x0080, _ ; WM_SETICON
            "dword", 1, _ ; 1 = ICON_BIG, 0 = ICON_SMALL
            "ptr", $hIcon)

EndFunc   ;==>_GUISetIcon

That will change the SciTE icon if you are running scripts there.

Hello, thanks for reply but still you did not understand my request - I want to know some way how to change icon of ANY application, not just my script. Can this code be used someway like running some exe file from my script via run and then change icon of its window for example?

Share this post


Link to post
Share on other sites

I want to know some way how to change icon of ANY application, not just my script.

Substitute the window handle of your application for the first param of the function.

Share this post


Link to post
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
Sign in to follow this  
Followers 0