Понял, оно работает только если запускать ahk с папки, а я с редактора запускал.
Пытаюсь всунуть в прогу, но иконка берётся не с пути к папке а с проги xplorer2, что я не так сделал?
#NoTrayIcon
SetTitleMatchMode, 2
;global Icon1 := GetSysImgListIcon(global FilePath, sz[16])
;Icon2 := GetSysImgListIcon(FilePath, sz[32])
;Icon3 := GetSysImgListIcon(FilePath, sz[48])
;Icon4 := GetSysImgListIcon(FilePath, sz[256])
iconFilet := "C:\staff\torrent.ico"
iconFiles := "C:\staff\ahk.ico"
iconFile := "C:\staff\explorer.ico"
hIcont := LoadPicture(iconFilet, "w16 h-1", IMAGE_ICON)
hIcons := LoadPicture(iconFiles, "w16 h-1", IMAGE_ICON)
hIcon := LoadPicture(iconFile, "w16 h-1", IMAGE_ICON)
#IfWinActive, ahk_exe xplorer2_64.exe
changed = 0
~LButton::
~RButton::
WinWait, xplorer2
IMAGE_ICON := 1, WM_SETICON := 0x80, ICON_BIG := 1, ICON_SMALL := 0
sz := { 16: "SMALL", 32: "LARGE", 48: "EXTRALARGE", 256: "JUMBO" }
WinGetTitle, Title, A
;var := RegExMatch(title, "\-(.*)", match)
var := RegExMatch(title, "(.*)- xplorer2", match)
var := match1
var1 = %match1%
FilePath := var1
Icon1 := GetSysImgListIcon(FilePath, sz[16])
ToolTip, %FilePath%
IfInString, changed, 1
{
SendMessage, 0x80, 0, hIcon, , xplorer2
changed := 0
}
;IfInString, var, TORRENTS
;{
;SendMessage, 0x80, 0, hIcont, , xplorer2
;changed = 1
;}
IfInString, var, staff
{
SendMessage, 0x80, 0, hIcons, , xplorer2
changed = 1
}
;ToolTip, 1 %changed%
sleep, 1000
SendMessage, WM_SETICON, ICON_SMALL, Icon1.HICON, , xplorer2
SendMessage, 0xC, 0, ""var, , xplorer2
GetSysImgListIcon(Path, Size := "SYSSMALL", Overlay := "") {
static SHIL := { LARGE: 0x00, SMALL: 0x01, EXTRALARGE: 0x02, SYSSMALL: 0x03, JUMBO: 0x04 } ; возможные размеры
, AW := A_IsUnicode ? "W" : "A"
, cbSFI := A_PtrSize + 8 + (340 << A_IsUnicode)
, IID_IIL_Str := "{46EB5926-582E-4017-9FDF-E8998DAA0950}"
, SHGFI := {SYSICONINDEX: 0x4000, PIDL: 0x8}
, SHGIOI := {SHARE: 0x0FFFFFFF, LINK: 0x0FFFFFFE, SLOWFILE: 0x0FFFFFFD, DEFAULT: 0x0FFFFFFC}
, ILD_IMAGE := 0x20
VarSetCapacity(IID_IIL, 16, 0) ; IID
DllCall("Ole32\IIDFromString", WStr, IID_IIL_Str, Ptr, &IID_IIL, UInt)
HMOD := DllCall("GetModuleHandle", Str, "shell32.dll", UPtr)
FileIconInit := DllCall("GetProcAddress", Ptr, HMOD, Ptr, 660, UPtr)
DllCall(FileIconInit, UInt, True, UInt)
VarSetCapacity(SFI, cbSFI, 0) ; SHFILEINFO
DllCall("Shell32\SHParseDisplayName", Str, path, Ptr, 0, PtrP, ppidl, UInt, 0, UIntP, 0)
Flags := SHGFI.PIDL | SHGFI.SYSICONINDEX
if !DllCall("Shell32\SHGetFileInfo" . AW, Ptr, ppidl, UInt, 0, Ptr, &SFI, UInt, cbSFI, UInt, Flags, UPtr)
Return False
IconIndex := NumGet(SFI, A_PtrSize, "Int")
if DllCall("Shell32\SHGetImageList", Int, SHIL[Size], Ptr, &IID_IIL, PtrP, IIL, UInt)
Return False
Flags := ILD_IMAGE
if SHGIOI.HasKey(Overlay)
&& (IOV := DllCall("Shell32\SHGetIconOverlayIndex", Ptr, 0, UInt, SHGIOI[Overlay], Int)) >= 0
Flags |= IOV << 8
DllCall("Comctl32\ImageList_GetIconSize", Ptr, IIL, IntP, CX, IntP, CY, UInt)
hIcon := DllCall("Comctl32\ImageList_GetIcon", Ptr, IIL, Int, IconIndex, UInt, Flags, UPtr)
Return { HICON: hIcon, W: CX, H: CY }
}
Но если запускаю ваш срипт, то он берёт иконку папки путь к которой указал в filepath, не пойму в чём заковыка...