Jump to content

change icon of the running application


LoWang
 Share

Recommended Posts

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.

Link to comment
Share on other sites

Link to comment
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

Link to comment
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?
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...