<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12183&amp;type=atom" />
	<updated>2023-06-28T06:24:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12183</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158626#p158626" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Так можно:<br /></p><div class="codebox"><pre><code>filePath := &quot;D:\Downloads\Аватар Путь воды_2022_WEB-DLRip-AVC.mkv&quot;
Gui, Add, Pic,, % &quot;HBITMAP:&quot; . GetThumbnailOrIcon(filePath, 48, 48, true)
Gui, Add, Pic, x+0 yp, % &quot;HBITMAP:&quot; . GetThumbnailOrIcon(filePath, 400)
Gui, Show
Return

GuiClose:
GuiEscape:
   ExitApp
   
GetThumbnailOrIcon(filePath, width, height := 0, iconOnly := false) {
   static IID_IShellItemImageFactory := &quot;{BCC18B79-BA16-442F-80C4-8A59C30C463B}&quot;
        , SIIGBF_BIGGERSIZEOK := 0x00000001
        , SIIGBF_ICONONLY     := 0x00000004
   
   VarSetCapacity(GUID, 16, 0)
   DllCall(&quot;Ole32\IIDFromString&quot;, &quot;WStr&quot;, IID_IShellItemImageFactory, &quot;Ptr&quot;, &amp;GUID)
   hr := DllCall(&quot;Shell32\SHCreateItemFromParsingName&quot;, &quot;WStr&quot;, filePath, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, &amp;GUID, &quot;PtrP&quot;, IShellItemImageFactory)
   if (hr != 0)
      Return 0
   flag := SIIGBF_BIGGERSIZEOK, (iconOnly &amp;&amp; flag |= SIIGBF_ICONONLY)
   ; IShellItemImageFactory::GetImage
   DllCall(NumGet(NumGet(IShellItemImageFactory+0) + A_PtrSize*3), &quot;Ptr&quot;, IShellItemImageFactory, &quot;Int64&quot;, height &lt;&lt; 32 | width
                                                                                                , &quot;Int&quot;, flag, &quot;PtrP&quot;, hBitmap, &quot;Int&quot;)
   ObjRelease(IShellItemImageFactory)
   Return hBitmap
}</code></pre></div></blockquote></div><p>А возможно как то сделать, чтобы не было рамки черной вокруг значка, и не было инвертирования цветов?</p><p><span class="postimg"><img src="https://i.imgur.com/cWeKLwO.png" alt="https://i.imgur.com/cWeKLwO.png" /></span></p><p>Если использовать иконки в формате ICO, то всё отлично.</p><br /><div class="codebox"><pre><code>
Menu, MyMenu, Add,  Мои документы, Return, +Break 
Menu, MyMenu, Icon, Мои документы, % &quot;HBITMAP:&quot; GetThumbnailOrIcon(A_MyDocuments, 512), , 48
Menu, MyMenu, Add,  Startup, Return
Menu, MyMenu, Icon, Startup, % &quot;HBITMAP:&quot; GetThumbnailOrIcon(A_Startup, 512), , 48
Menu, MyMenu, Color, C0C0C0
Menu, MyMenu, Show
Return
Return:
	Return
 
 
GetThumbnailOrIcon(filePath, width, height := 0, iconOnly := false) {
   static IID_IShellItemImageFactory := &quot;{BCC18B79-BA16-442F-80C4-8A59C30C463B}&quot;
        , SIIGBF_BIGGERSIZEOK := 0x00000001
        , SIIGBF_ICONONLY     := 0x00000004
   
   VarSetCapacity(GUID, 16, 0)
   DllCall(&quot;Ole32\IIDFromString&quot;, &quot;WStr&quot;, IID_IShellItemImageFactory, &quot;Ptr&quot;, &amp;GUID)
   hr := DllCall(&quot;Shell32\SHCreateItemFromParsingName&quot;, &quot;WStr&quot;, filePath, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, &amp;GUID, &quot;PtrP&quot;, IShellItemImageFactory)
   if (hr != 0)
      Return 0
   flag := SIIGBF_BIGGERSIZEOK, (iconOnly &amp;&amp; flag |= SIIGBF_ICONONLY)
   ; IShellItemImageFactory::GetImage
   DllCall(NumGet(NumGet(IShellItemImageFactory+0) + A_PtrSize*3), &quot;Ptr&quot;, IShellItemImageFactory, &quot;Int64&quot;, height &lt;&lt; 32 | width
                                                                                                , &quot;Int&quot;, flag, &quot;PtrP&quot;, hBitmap, &quot;Int&quot;)
   ObjRelease(IShellItemImageFactory)
   Return hBitmap
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-06-28T06:24:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158626#p158626</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158378#p158378" />
			<content type="html"><![CDATA[<p>ПС:<br />Разобрался, работает вместо LoadImage, почему то первые тесты с ней были не удачные.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-27T11:29:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158378#p158378</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158377#p158377" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>что то я запутался.</p></blockquote></div><p>Да, запутался, это неверно.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Но в меню работает только по типу HICON, HBITMAP не работает.</p></blockquote></div><p>Надо было просто указать IMAGE_BITMAP.</p><p>Тогда как переделать пример из #23, чтобы работало выравнивание (align)?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-27T11:27:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158377#p158377</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158376#p158376" />
			<content type="html"><![CDATA[<p>Я видел по названию hBitmap. Но в меню работает только по типу HICON, HBITMAP не работает.</p><p>Если тут вместо PrivateExtractIcons вставить то что вернёт GetThumbnailOrIcon, то не работает, что то я запутался.</p><div class="codebox"><pre><code>ico = 01.ico

icoINd := 0
align := 4
cx := cy := 32 

Gui, Add, Button, w32 h32 xm hwndhBtn
himl := DllCall(&quot;ImageList_Create&quot;, &quot;UInt&quot;,cx, &quot;UInt&quot;,cy, &quot;UInt&quot;,0x20, &quot;UInt&quot;,1, &quot;UInt&quot;,5)
 
SplitPath, ico, , , ext
if (ext = &quot;bmp&quot;) {
	hbmp := DllCall(&quot;LoadImage&quot;, &quot;UInt&quot;,0, &quot;Str&quot;, ico, &quot;UInt&quot;,0, &quot;UInt&quot;,cx, &quot;UInt&quot;,cy, &quot;UInt&quot;,0x10)
	DllCall(&quot;ImageList_Add&quot;, &quot;UInt&quot;,himl, &quot;UInt&quot;,hbmp, &quot;UInt&quot;,0)
	DllCall(&quot;DeleteObject&quot;, &quot;UInt&quot;, hbmp)
}
else {
	DllCall(&quot;PrivateExtractIcons&quot;, &quot;Str&quot;, ico, &quot;UInt&quot;, icoINd, &quot;UInt&quot;,cx, &quot;UInt&quot;,cy, &quot;UIntP&quot;, hicon, &quot;UInt&quot;,0, &quot;UInt&quot;,1, &quot;UInt&quot;,0)
 	DllCall(&quot;ImageList_AddIcon&quot;, &quot;UInt&quot;,himl, &quot;UInt&quot;,hicon)
	DllCall(&quot;DestroyIcon&quot;, &quot;UInt&quot;, hicon) 
}

VarSetCapacity(struct, 24)
NumPut(himl, struct, 0, &quot;UInt&quot;)
NumPut(align, struct, 20, &quot;UInt&quot;)
; BCM_FIRST := 0x1600, BCM_SETIMAGELIST := BCM_FIRST + 0x2
PostMessage, 0x1602, 0, &amp;struct, , ahk_id %hBtn%
Gui, Show 
return </code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-27T10:16:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158376#p158376</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158375#p158375" />
			<content type="html"><![CDATA[<p>Смотри, что функция GetThumbnailOrIcon() возвращает.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-05-27T09:49:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158375#p158375</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158374#p158374" />
			<content type="html"><![CDATA[<p>В меню работает, а с кнопкой почему то не работает.</p><div class="codebox"><pre><code>
filePath = C:\

Gui, +AlwaysOnTop -Border +HWNDhGui -Caption
Gui, Add, Button, x0 y0 w32 h32 hwndhBut
ButtonSetIcon(hBut, filePath, 32)
Gui, Show, w32 h32
Return 

GuiClose:
GuiEscape:
	ExitApp 

ButtonSetIcon(Hwnd, sFile, IconSize)  { 
	Static BM_SETIMAGE := 0xF7, IMAGE_ICON := 1, BS_ICON := 0x40 
	hIcon := GetThumbnailOrIcon(sFile, IconSize) 
	Control, Style, +%BS_ICON%, , % &quot;ahk_id&quot; Hwnd 
	PostMessage, BM_SETIMAGE, IMAGE_ICON, hIcon		,, % &quot;ahk_id&quot; Hwnd  
} 
 
GetThumbnailOrIcon(filePath, width, height := 0, iconOnly := false) {
   static IID_IShellItemImageFactory := &quot;{BCC18B79-BA16-442F-80C4-8A59C30C463B}&quot;
        , SIIGBF_BIGGERSIZEOK := 0x00000001
        , SIIGBF_ICONONLY     := 0x00000004
   
   VarSetCapacity(GUID, 16, 0)
   DllCall(&quot;Ole32\IIDFromString&quot;, &quot;WStr&quot;, IID_IShellItemImageFactory, &quot;Ptr&quot;, &amp;GUID)
   hr := DllCall(&quot;Shell32\SHCreateItemFromParsingName&quot;, &quot;WStr&quot;, filePath, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, &amp;GUID, &quot;PtrP&quot;, IShellItemImageFactory)
   if (hr != 0)
      Return 0
   flag := SIIGBF_BIGGERSIZEOK, (iconOnly &amp;&amp; flag |= SIIGBF_ICONONLY)
   ; IShellItemImageFactory::GetImage
   DllCall(NumGet(NumGet(IShellItemImageFactory+0) + A_PtrSize*3), &quot;Ptr&quot;, IShellItemImageFactory, &quot;Int64&quot;, height &lt;&lt; 32 | width
                                                                                                , &quot;Int&quot;, flag, &quot;PtrP&quot;, hBitmap, &quot;Int&quot;)
   ObjRelease(IShellItemImageFactory)
   Return hBitmap
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-27T09:34:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158374#p158374</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158324#p158324" />
			<content type="html"><![CDATA[<p>Не, давно уже было.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-05-23T19:42:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158324#p158324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158322#p158322" />
			<content type="html"><![CDATA[<p>Ну ты молодца!<br />Так сходу накопал?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-23T19:13:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158322#p158322</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158321#p158321" />
			<content type="html"><![CDATA[<p>Так можно:<br /></p><div class="codebox"><pre><code>filePath := &quot;D:\Downloads\Аватар Путь воды_2022_WEB-DLRip-AVC.mkv&quot;
Gui, Add, Pic,, % &quot;HBITMAP:&quot; . GetThumbnailOrIcon(filePath, 48, 48, true)
Gui, Add, Pic, x+0 yp, % &quot;HBITMAP:&quot; . GetThumbnailOrIcon(filePath, 400)
Gui, Show
Return

GuiClose:
GuiEscape:
   ExitApp
   
GetThumbnailOrIcon(filePath, width, height := 0, iconOnly := false) {
   static IID_IShellItemImageFactory := &quot;{BCC18B79-BA16-442F-80C4-8A59C30C463B}&quot;
        , SIIGBF_BIGGERSIZEOK := 0x00000001
        , SIIGBF_ICONONLY     := 0x00000004
   
   VarSetCapacity(GUID, 16, 0)
   DllCall(&quot;Ole32\IIDFromString&quot;, &quot;WStr&quot;, IID_IShellItemImageFactory, &quot;Ptr&quot;, &amp;GUID)
   hr := DllCall(&quot;Shell32\SHCreateItemFromParsingName&quot;, &quot;WStr&quot;, filePath, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, &amp;GUID, &quot;PtrP&quot;, IShellItemImageFactory)
   if (hr != 0)
      Return 0
   flag := SIIGBF_BIGGERSIZEOK, (iconOnly &amp;&amp; flag |= SIIGBF_ICONONLY)
   ; IShellItemImageFactory::GetImage
   DllCall(NumGet(NumGet(IShellItemImageFactory+0) + A_PtrSize*3), &quot;Ptr&quot;, IShellItemImageFactory, &quot;Int64&quot;, height &lt;&lt; 32 | width
                                                                                                , &quot;Int&quot;, flag, &quot;PtrP&quot;, hBitmap, &quot;Int&quot;)
   ObjRelease(IShellItemImageFactory)
   Return hBitmap
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-05-23T18:47:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158321#p158321</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158320#p158320" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Не знаю, у меня работает. Надо смотреть, что функция возвращает в Icon2.W.<br /></p><div class="codebox"><pre><code>FilePath := A_WinDir

WM_SETICON := 0x80, ICON_BIG := 1, ICON_SMALL := 0
sz := { 16: &quot;SMALL&quot;, 32: &quot;LARGE&quot;, 48: &quot;EXTRALARGE&quot;, 256: &quot;JUMBO&quot; }

Icon1 := GetSysImgListIcon(FilePath, sz[16])
Icon2 := GetSysImgListIcon(FilePath, sz[32])
Icon3 := GetSysImgListIcon(FilePath, sz[48])
Icon4 := GetSysImgListIcon(FilePath, sz[256])

MsgBox, % Icon2.W

Gui, +LastFound
Gui, Add, Pic, % &quot;w&quot; Icon2.W &quot; h&quot; Icon2.H, % &quot;HICON:&quot; Icon2.HICON
Gui, Add, Pic, % &quot;x+10 yp w&quot; Icon3.W &quot; h&quot; Icon3.H, % &quot;HICON:&quot; Icon3.HICON
Gui, Add, Pic, % &quot;x+10 yp w&quot; Icon4.W &quot; h&quot; Icon4.H, % &quot;HICON:&quot; Icon4.HICON
SendMessage, WM_SETICON, ICON_SMALL, Icon1.HICON  ; иконка в строке заголовка
SendMessage, WM_SETICON, ICON_BIG  , Icon2.HICON  ; иконка для Alt + Tab
Gui, Show
Return

GuiClose:
   ExitApp

GetSysImgListIcon(Path, Size := &quot;SYSSMALL&quot;, Overlay := &quot;&quot;)  {
   static SHIL := { LARGE: 0x00, SMALL: 0x01, EXTRALARGE: 0x02, SYSSMALL: 0x03, JUMBO: 0x04 }  ; возможные размеры
        , AW := A_IsUnicode ? &quot;W&quot; : &quot;A&quot;
        , cbSFI := A_PtrSize + 8 + (340 &lt;&lt; A_IsUnicode)
        , IID_IIL_Str := &quot;{46EB5926-582E-4017-9FDF-E8998DAA0950}&quot;
        , SHGFI := {SYSICONINDEX: 0x4000, PIDL: 0x8}
        , SHGIOI := {SHARE: 0x0FFFFFFF, LINK: 0x0FFFFFFE, SLOWFILE: 0x0FFFFFFD, DEFAULT: 0x0FFFFFFC}
        , ILD_IMAGE := 0x20
   
   VarSetCapacity(IID_IIL, 16, 0) ; IID
   DllCall(&quot;Ole32\IIDFromString&quot;, WStr, IID_IIL_Str, Ptr, &amp;IID_IIL, UInt)
   
   HMOD := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;shell32.dll&quot;, UPtr)
   FileIconInit := DllCall(&quot;GetProcAddress&quot;, Ptr, HMOD, Ptr, 660, UPtr)
   DllCall(FileIconInit, UInt, True, UInt)
   
   VarSetCapacity(SFI, cbSFI, 0) ; SHFILEINFO
   DllCall(&quot;Shell32\SHParseDisplayName&quot;, Str, path, Ptr, 0, PtrP, ppidl, UInt, 0, UIntP, 0)
   Flags := SHGFI.PIDL | SHGFI.SYSICONINDEX
   if !DllCall(&quot;Shell32\SHGetFileInfo&quot; . AW, Ptr, ppidl, UInt, 0, Ptr, &amp;SFI, UInt, cbSFI, UInt, Flags, UPtr)
      Return False
   
   IconIndex := NumGet(SFI, A_PtrSize, &quot;Int&quot;)
   if DllCall(&quot;Shell32\SHGetImageList&quot;, Int, SHIL[Size], Ptr, &amp;IID_IIL, PtrP, IIL, UInt)
      Return False
   
   Flags := ILD_IMAGE
   if SHGIOI.HasKey(Overlay)
   &amp;&amp; (IOV := DllCall(&quot;Shell32\SHGetIconOverlayIndex&quot;, Ptr, 0, UInt, SHGIOI[Overlay], Int)) &gt;= 0
      Flags |= IOV &lt;&lt; 8
      
   DllCall(&quot;Comctl32\ImageList_GetIconSize&quot;, Ptr, IIL, IntP, CX, IntP, CY, UInt)
   hIcon := DllCall(&quot;Comctl32\ImageList_GetIcon&quot;, Ptr, IIL, Int, IconIndex, UInt, Flags, UPtr)
   
   Return { HICON: hIcon, W: CX, H: CY }
}</code></pre></div></blockquote></div><p>А возможно как то получить превью с проводника из имени файла?<br />То есть не ассоциированную иконку, а например как у видео файлов, тот кадр который отображается.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2023-05-23T15:21:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158320#p158320</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109469#p109469" />
			<content type="html"><![CDATA[<p>Ок, только точки расставьте.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-11-28T14:22:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109469#p109469</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109468#p109468" />
			<content type="html"><![CDATA[<p>Блин, а всё оказалось тотально проще.</p><div class="codebox"><pre><code>FileName = %match1% ; путь к папке иконка которой будет показываться
	hIcon := DllCall(&quot;Shell32\ExtractAssociatedIconA&quot;, UInt, 0, Str, FileName, UShortP, iIndex)

SendMessage, 0x80, 0, hIcon, , xplorer2</code></pre></div><p>Маленький и рабочий код по получению иконки.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2016-11-28T13:06:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109468#p109468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109467#p109467" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, так вроде для проверки поставил ToolTip, %FilePath% в тултипе путь правильный - к папке, но иконка не с папки. Да и Бог с ним, главное я реализовал. Спасибо ещё раз за указание на ошибку, с вашей подсказкой всё легко решилось.</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2016-11-28T12:13:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109467#p109467</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109466#p109466" />
			<content type="html"><![CDATA[<p>Какой путь у вас указан, оттуда и берётся.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-11-28T11:03:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109466#p109466</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Убрать или заменить иконку в верхнем левом углу окна любой прог..]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109464#p109464" />
			<content type="html"><![CDATA[<p>Понял, оно работает только если запускать ahk с папки, а я с редактора запускал.</p><p>Пытаюсь всунуть в прогу, но иконка берётся не с пути к папке а с проги xplorer2, что я не так сделал?</p><div class="codebox"><pre><code>#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 := &quot;C:\staff\torrent.ico&quot;
iconFiles := &quot;C:\staff\ahk.ico&quot;
iconFile := &quot;C:\staff\explorer.ico&quot;
hIcont := LoadPicture(iconFilet, &quot;w16 h-1&quot;, IMAGE_ICON)
hIcons := LoadPicture(iconFiles, &quot;w16 h-1&quot;, IMAGE_ICON)
hIcon := LoadPicture(iconFile, &quot;w16 h-1&quot;, 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: &quot;SMALL&quot;, 32: &quot;LARGE&quot;, 48: &quot;EXTRALARGE&quot;, 256: &quot;JUMBO&quot; }

WinGetTitle, Title, A
;var := RegExMatch(title, &quot;\-(.*)&quot;, match)
var := RegExMatch(title, &quot;(.*)- xplorer2&quot;, 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, &quot;&quot;var, , xplorer2

GetSysImgListIcon(Path, Size := &quot;SYSSMALL&quot;, Overlay := &quot;&quot;)  {
   static SHIL := { LARGE: 0x00, SMALL: 0x01, EXTRALARGE: 0x02, SYSSMALL: 0x03, JUMBO: 0x04 }  ; возможные размеры
        , AW := A_IsUnicode ? &quot;W&quot; : &quot;A&quot;
        , cbSFI := A_PtrSize + 8 + (340 &lt;&lt; A_IsUnicode)
        , IID_IIL_Str := &quot;{46EB5926-582E-4017-9FDF-E8998DAA0950}&quot;
        , SHGFI := {SYSICONINDEX: 0x4000, PIDL: 0x8}
        , SHGIOI := {SHARE: 0x0FFFFFFF, LINK: 0x0FFFFFFE, SLOWFILE: 0x0FFFFFFD, DEFAULT: 0x0FFFFFFC}
        , ILD_IMAGE := 0x20
   
   VarSetCapacity(IID_IIL, 16, 0) ; IID
   DllCall(&quot;Ole32\IIDFromString&quot;, WStr, IID_IIL_Str, Ptr, &amp;IID_IIL, UInt)
   
   HMOD := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;shell32.dll&quot;, UPtr)
   FileIconInit := DllCall(&quot;GetProcAddress&quot;, Ptr, HMOD, Ptr, 660, UPtr)
   DllCall(FileIconInit, UInt, True, UInt)
   
   VarSetCapacity(SFI, cbSFI, 0) ; SHFILEINFO
   DllCall(&quot;Shell32\SHParseDisplayName&quot;, Str, path, Ptr, 0, PtrP, ppidl, UInt, 0, UIntP, 0)
   Flags := SHGFI.PIDL | SHGFI.SYSICONINDEX
   if !DllCall(&quot;Shell32\SHGetFileInfo&quot; . AW, Ptr, ppidl, UInt, 0, Ptr, &amp;SFI, UInt, cbSFI, UInt, Flags, UPtr)
      Return False
   
   IconIndex := NumGet(SFI, A_PtrSize, &quot;Int&quot;)
   if DllCall(&quot;Shell32\SHGetImageList&quot;, Int, SHIL[Size], Ptr, &amp;IID_IIL, PtrP, IIL, UInt)
      Return False
   
   Flags := ILD_IMAGE
   if SHGIOI.HasKey(Overlay)
   &amp;&amp; (IOV := DllCall(&quot;Shell32\SHGetIconOverlayIndex&quot;, Ptr, 0, UInt, SHGIOI[Overlay], Int)) &gt;= 0
      Flags |= IOV &lt;&lt; 8
      
   DllCall(&quot;Comctl32\ImageList_GetIconSize&quot;, Ptr, IIL, IntP, CX, IntP, CY, UInt)
   hIcon := DllCall(&quot;Comctl32\ImageList_GetIcon&quot;, Ptr, IIL, Int, IconIndex, UInt, Flags, UPtr)
   
   Return { HICON: hIcon, W: CX, H: CY }
}</code></pre></div><p>Но если запускаю ваш срипт, то он берёт иконку папки путь к которой указал в filepath, не пойму в чём заковыка...</p>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2016-11-28T08:23:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109464#p109464</id>
		</entry>
</feed>
