Set Script Icon in Alt+Tab Window
Posted: 04 Jul 2016, 03:08
Under the Window Appearance section of the GUI help topic, there is some code to load an icon that will show up in the Alt+Tab Task Switcher...
This code (above) requires the use of an external icon file.
I use shell32.dll icons in many cases, in order to avoid the need for external icon files, and the limited selection of icons in shell32.dll suits the limited number of cases where I actually need to do this.
This works just fine for setting a tray icon, for example...
On the other hand, I have been unable to get the shell32.dll icons to show up as a large icon in the Alt+Tab Task Switcher.
This code below doesn't work--an attempt at adapting the help topic code above.
If anyone sees any mistakes in the DLL call arguments please let me know... this code is executed before the GUI is created via Gui, Show
Code: Select all
hIcon32 := DllCall("LoadImage", uint, 0
, str, "My Icon.ico" ; Icon filename (this file may contain multiple icons).
, uint, 1 ; Type of image: IMAGE_ICON
, int, 32, int, 32 ; Desired width and height of image (helps LoadImage decide which icon is best).
, uint, 0x10) ; Flags: LR_LOADFROMFILE
Gui +LastFound
SendMessage, 0x80, 1, hIcon32 ; 0x80 is WM_SETICON; and 1 means ICON_BIG (vs. 0 for ICON_SMALL).
Gui Show
I use shell32.dll icons in many cases, in order to avoid the need for external icon files, and the limited selection of icons in shell32.dll suits the limited number of cases where I actually need to do this.
This works just fine for setting a tray icon, for example...
Code: Select all
;-----------------------------------------------------------------------------
; Create small icon for the tray
;-----------------------------------------------------------------------------
Menu, Tray, Icon, Shell32.dll, 255
;-----------------------------------------------------------------------------
This code below doesn't work--an attempt at adapting the help topic code above.
If anyone sees any mistakes in the DLL call arguments please let me know... this code is executed before the GUI is created via Gui, Show
Code: Select all
;-----------------------------------------------------------------------------
; Create large icon for Alt+Tab switch window
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx
;-----------------------------------------------------------------------------
hIcon32 := DllCall("LoadImage", unit, hInst:=DllCall("GetModuleHandle", str, "Shell32.dll")
, str, "#255" ; Icon resource # within DLL
, uint, IMAGE_ICON:=1
, int, IcoWidth:=32, int, IcoHeight:=32 ; Desired width and height of image (helps LoadImage decide which icon is best).
, uint, Flags:=0)
SendMessage, WM_SETICON:=0x80, ICON_BIG:=1, hIcon32