Alt-tab icon is okay
Tray icon is blank
Title-bar icon is default (Green-H)
AutoHotkey v1.1.26.00 on Windows 7 x64
What Am I missing?
Code: Select all
#NoEnv
#SingleInstance, Force
#NoTrayIcon
hIcon := LoadPicture( "user32.dll", "Icon5 w16 h16", VType )
Menu, Tray, Icon, HICON:%hIcon%
Menu, Tray, Icon
Gui, Show, w200 h200, Testing
Return
Actually I am trying to generate and use Icon with in-script base64 PNG data.
Ref: Base64 to HICON : Native PNG Decompression (requires WIN VISTA and later)
Solution:
Menu, Tray, Icon, HICON:*%hICON%
Code: Select all
; Ask for help topic: https://autohotkey.com/boards/viewtopic.php?t=36640
#NoEnv
#SingleInstance, Force
#NoTrayIcon
Menu, Tray, UseErrorLevel
hICON := Base64toHICON() ; Create a HICON
Menu, Tray, Icon, HICON:*%hICON% ; AHK makes a copy of HICON when * is used
Menu, Tray, Icon
DllCall( "DestroyIcon", "Ptr",hICON ) ; Destroy original HICON
Gui, Show, w400 h200, TrayIcon with in-script Base64 PNG image raw data
Return
Base64toHICON() { ; 16x16 PNG image (236 bytes), requires WIN Vista and later
Local B64 := "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAs0lEQVQ4jbXTO27CUBCF4e9a7rIJECugZ"
. "QlZQhoUSmihg8rpqKEOTZbAEihhBUjsxBSWEZYY2Qrwl/fM49zRTDoWYIwVBrpxRoFdjik2HRNrBvjFR455/TpclreI0"
. "09qZATaPEPvUYu/Q9z+TutlSHFoKyl7IhnkkbDel5HU4H0OFp/N0USOwgLwNWp38PQXXlKg27gfU+a4oE+1otEGBtolH"
. "Yt/HVPNLMMWE9WJduWMb2yvxO4l4nkelNAAAAAASUVORK5CYII=", Bin, Blen, nBytes:=236, hICON:=0
VarSetCapacity( Bin,nBytes,0 ), BLen := StrLen(B64)
If DllCall( "Crypt32.dll\CryptStringToBinary", "Str",B64, "UInt",BLen, "UInt",0x1
, "Ptr",&Bin, "UIntP",nBytes, "Int",0, "Int",0 )
hICON := DllCall( "CreateIconFromResourceEx", "Ptr",&Bin, "UInt",nBytes, "Int",True
, "UInt",0x30000, "Int",16, "Int",16, "UInt",0, "UPtr" )
Return hICON
}