<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=9636&amp;type=atom" />
	<updated>2014-12-04T10:47:40Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=9636</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88859#p88859" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>SKAN пишет:</cite><blockquote><div class="codebox"><pre><code>DllCall( &quot;shlwapi\SHAutoComplete&quot;, UInt,hMyEdit, UInt,0x1|0x10000000 )</code></pre></div></blockquote></div><p>Здесь хэндл с типом &quot;UInt&quot;, сработает только на 32-bit. На AHK_L это ошибка, принято писать &quot;Ptr&quot;. То-есть, для практического использования подойдёт, а для примера кодинга — не очень.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-04T10:47:40Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88859#p88859</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88858#p88858" />
			<content type="html"><![CDATA[<p>У меня 32-bit, но версия 1.1.13.1 Unicode (XP SP3).</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-12-04T10:42:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88858#p88858</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88857#p88857" />
			<content type="html"><![CDATA[<p>Только под 32-bit. Скорее всего, под AHK-basic написано.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-04T10:23:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88857#p88857</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88855#p88855" />
			<content type="html"><![CDATA[<p>Иконки отображаются, извлекаются.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-12-04T10:16:01Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88855#p88855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88854#p88854" />
			<content type="html"><![CDATA[<p>И?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-04T10:11:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88854#p88854</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88853#p88853" />
			<content type="html"><![CDATA[<p>Да.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-12-04T10:08:31Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88853#p88853</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88852#p88852" />
			<content type="html"><![CDATA[<p>Запускал?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-04T09:56:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88852#p88852</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88851#p88851" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А на код ссылка есть?</p></blockquote></div><p><span class="postimg"><img src="http://i.smiles2k.net/aiwan_smiles/no.gif" alt="http://i.smiles2k.net/aiwan_smiles/no.gif" /></span></p><p>Есть сам код, еле нашёл <a href="http://ahkscript.org/forum/viewtopic.php?p=239941#239941">здесь</a>: <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p><div class="codebox"><pre><code>; IconEx v1.2b by SKAN ( arian.suresh@gmail.com )  ||   CD: 13-May-2008 |  LM: 27-Dec-2008
DllCall( &quot;LoadLibrary&quot;, Str,&quot;Shell32.dll&quot;)
#SingleInstance, Force
SetWorkingDir %A_ScriptDir% 
SetBatchLines, -1
Process, Priority,, High

SaveButton := 0x79 -1   ; ( VK code for F9 ) Note: modify -1 to -2 for F8 and so on...
KeyName := &quot;F9&quot;         ; depends on the VK code you use above
Deff    := A_ScriptDir  ; Default ICON save folder
CallB   := RegisterCallback( &quot;EnumResNameProc&quot; )
tFolder := A_WinDir &quot;\SYSTEM32\SHELL32.DLL&quot; ; default folder in address bar
IfExist, %A_Temp%\IconEx.tmp
 {
   FileRead, tFolder, %A_Temp%\IconEx.tmp
   FileDelete, %A_Temp%\IconEx.tmp   
 }
 
EnumResNameProc( hModule, lpszType, lpszName, lParam ) {
 Global IconGroups, IGCount
 IconGroups .= ( ( IconGroups!=&quot;&quot; ) ? &quot;|&quot; : &quot;&quot; ) . lpszName , IGCount:=IGCount+1 
 Return True
}

Gui,Font, s10 Normal, Tahoma
; SHAutoComplete():  Sean - http://www.autohotkey.com/forum/viewtopic.php?p=121621#121621
; For constants : http://www.codeproject.com/KB/edit/autocomp.aspx
Gui, Add, Combobox, x7 y7 w550 h21 Choose1 -Theme hwndhSHAC vtFolder, %tFolder%
ControlGet, hMyEdit, hWnd,, Edit1, ahk_id %hSHAC%

DllCall( &quot;ole32\CoInitialize&quot;, UInt,0 )
DllCall( &quot;shlwapi\SHAutoComplete&quot;, UInt,hMyEdit, UInt,0x1|0x10000000 )
; DllCall( &quot;ole32\CoUninitialize&quot; ) ; In Vista: Crashes AHK On Exit
 
Gui,Font, s8 Normal, Tahoma
Gui, Add, Button, x+2 w33 h24 +Default gUpdateResourceList, &amp;Go
Gui, Add, Button, x+2 w52 h24 gSelectFolder, &amp;Browse
Gui, Add, ListView, x7 y+5 h280 w235 -Theme -E0x200 +0x4 +0x8 +Border vLVR gLVR 
                   +BackGroundFFFFFA c444466 AltSubmit, Resource File|Icons|IconGroup
LV_ModifyCol( 1 ,&quot;170&quot; ), LV_ModifyCol( 2, &quot;42 Integer&quot; ), LV_ModifyCol( 3, &quot;0&quot; )
Gui, Add, ListView, x+0 yp h280 w405 -Theme +Icon -E0x200 +0x100
                   +BackGroundFFFFFC cBB2222 Border AltSubmit vLVI gLVI hwndLVC2
Gui, Add, Hotkey, x2 y+79 w1 h1 +Disabled vHotkey gCreateSimpleIcon
Loop 8 {
   Ix += 1 
   Gui, Add, Text,x+10 yp-70 0x1203 w70 h70 vI%Ix% hWndIcon%Ix% gSelectSimpleIcon
   Gui, Add, Text, xp  yp+70 0x201  w70 h16 vIconT%Ix%, -
} 
Gui, Add, Text, x2 y+79 w1 h1
Loop 8 {
   Ix += 1 
   Gui, Add, Text,x+10 yp-70 0x1203 w70 h70 vI%Ix% hWndIcon%Ix% gSelectSimpleIcon
   Gui, Add, Text, xp  yp+70 0x201  w70 h16 vIconT%Ix%, -
} 

Gui, Add, Button, X7 y+30 gAccelerator, &amp;File
Gui, Add, Button, x+5     gAccelerator, &amp;Icon
Gui, Add, Button, x+5     gAccelerator, A&amp;ddress Bar
Gui, Add, Button, x+5     gAccelerator, &amp;Reload
Gui,Font
Gui, Add, StatusBar, vSB gFindTarget
SB_SetParts( 40,425 )
GoSub, UpdateResourceList
SB_SetText( &quot;Type the path to a folder/file. Auto complete enabled&quot;, 2 )
Gui, Show, w655 h535 , IconEx - v1.0
Return                                                 ; // end of auto-execute section //

UpdateResourceList:
  SendInput, {Escape}
  ControlGetText,tFolder,, ahk_id %hSHAC%
  If ! InStr( FileExist( tFolder ), &quot;D&quot; ) 
    Folder := tFolder
  Else Folder := tFolder . &quot;\*.*&quot;
  GoSub, SetFolder
  Gui, ListView, LVI
  LV_Delete()
  Gui, ListView, LVR
  LV_Delete(), , SB_SetText( &quot;  Loading files.. Please wait&quot; , 2 ), FileCount := 0
  Loop, %Folder%  {
    If A_LoopFileExt Not in EXE,DLL,CPL,SCR
      Continue
    hModule := DllCall( &quot;LoadLibraryEx&quot;, Str,A_LoopFileLongPath, UInt,0, UInt,0x2 )
    IfEqual,hModule,0,Continue
    IGCount:=0, IconGroups := &quot;&quot;
    DllCall(&quot;EnumResourceNamesA&quot;, UInt,hModule, UInt,14, UInt,CallB, UInt,0 )
    DllCall( &quot;FreeLibrary&quot;, UInt,hModule )
    IfEqual,IGCount,0, Continue
    FileCount:=FileCount+1
    FileName := DllCall( &quot;CharUpperA&quot;, Str,A_LoopFileName, Str )
    Gui, ListView, LVR
    LV_ADD( &quot;&quot;, FileName, IGCount, IconGroups )
    SB_SetText( &quot;`t&quot; FileCount, 1 )
  }
  SB_SetText( &quot;`t&quot; FileCount, 1 ), SB_SetText( &quot;  Done!&quot; , 2 )
  GuiControl, Focus, LVR
  RowNo := 1
  GoSub, LVRSUB
  Gui, ListView, LVI
  LV_Modify( 1, &quot;Select&quot; )
  Gui, ListView, LVR
  GuiControl, Focus, LVR
  LV_Modify( 1, &quot;Select&quot; )
  GuiControl, Focus, tFolder
Return

LVR:
  If ( A_GuiEvent=&quot;k&quot; and ( A_EventInfo=40 or A_EventInfo=38 ) ) {
       RowNo := LV_GetNext( 0, &quot;Focused&quot; )
       GoTo, LVRSUB
       Return
  }
 
  If ( A_GuiEvent=&quot;k&quot; and A_EventInfo=SaveButton ) {
       RowNo := LV_GetNext( 0, &quot;Focused&quot; )
       IfNotEqual,RowNo,0, GoSub, ExtractIconRes
       Return
  }
  IfNotEqual, A_GuiEvent,Normal, Return
  RowNo := A_EventInfo
LVRSUB: 
  Gui, ListView, LVR
  LV_GetText( File, RowNo,1 ), LV_GetText( IGC, RowNo,2 ), LV_GetText( IG, RowNo,3 )
  SB_SetText( &quot;Press &lt;&quot; KeyName &quot;&gt; to save all icons in &quot; File , 2 ) 
  Gui, ListView, LVI
  LV_Delete()
  ImageListID ? IL_Destroy( ImageListID ) :
  ImageListID := IL_Create( 10,10,1 ), LV_SetImageList(ImageListID)
  Loop, %IGC%
        IL_Add(ImageListID, tFolder &quot;\&quot; File, A_Index )
  Loop, Parse, IG, |
       {
          Gui, ListView, LVI
          LV_Add(&quot;Icon&quot; . A_Index, A_LoopField )
       }     
  RowNo := 1
  GoSub, LVISUB
  Gui, ListView, LVR
Return

LVI:
  Gui, ListView, LVI
  If ( A_GuiEvent=&quot;k&quot; and ( A_EventInfo&gt;=37 and A_EventInfo&lt;=40 ) ) {
       RowNo := LV_GetNext( 0, &quot;Focused&quot; )
       LV_GetText( IconGroup, RowNo,1 ) 
       SB_SetText( &quot;Press &lt;&quot; KeyName &quot;&gt; to save the Icon Group &quot; IconGroup, 2 )
       GoTo, LVISUB
       Return
  }
  If ( A_GuiEvent=&quot;k&quot; and A_EventInfo=SaveButton ) {
       RowNo := LV_GetNext( 0, &quot;Focused&quot; )
       IfNotEqual,RowNo,0,GoSub, ExtractIcon
       Return
  }

  If ( A_GuiEvent=&quot;k&quot; and A_EventInfo=0x79 ) {
       GoSub, ApplyIconToFolder
       Return
  }
  IfNotEqual, A_GuiEvent,Normal, Return
  RowNo := A_EventInfo
  LV_GetText( IconGroup, RowNo,1 ) 
  SB_SetText( &quot;Press &lt;&quot; KeyName &quot;&gt; to save the Icon Group &quot; IconGroup, 2 )
LVISUB:
  Gui, ListView, LVI
  LV_GetText( IconGroup, RowNo,1 )
  hMod := DllCall( &quot;LoadLibraryEx&quot;, Str,tFolder &quot;\&quot; File, UInt,0, UInt,0x2 )
  Buff := GetResource( hMod, IconGroup, (RT_GROUP_ICON:=14), nSize, hResData )
  Icos := NumGet( Buff+4, 0, &quot;UShort&quot; ), Buff:=Buff+6
  SB_SetText( &quot;`t&quot; Icos &quot; Icons in &lt; Group &quot; IconGroup &quot; &gt;&quot;, 3 )
  Loop, %Icos% {
      W   := NumGet( Buff+0,0,&quot;UChar&quot; ),   H   := NumGet( Buff+0,1,&quot;UChar&quot; )
      BPP := NumGet( Buff+0,6,&quot;UShort&quot;),   nID := NumGet( Buff+0,12,&quot;UShort&quot;)
      If ( W+H = 0 ) {
        SendMessage, ( STM_SETIMAGE:=0x172 ), 0x1, 0,, % &quot;ahk_id &quot; Icon%A_Index%       
        DllCall( &quot;FreeResource&quot;, UInt,hResData )
        GuiControl,,IconT%A_Index%, - 
        Continue
      }
      Buff+=14
      IconD  := GetResource( hMod, nID, (RT_ICON:=3), nSize, hResData )
      Wi := ( W &gt; 64 ) ? 64 : W , Hi := ( H &gt; 64 ) ? 64 : H
      hIcon  := DllCall( &quot;CreateIconFromResourceEx&quot;, UInt,IconD, UInt,BPP, Int,1
                        , UInt, 0x00030000, Int,Wi, Int,Hi, UInt,(LR_SHARED := 0x8000) )
      SendMessage, ( STM_SETIMAGE:=0x172 ), 0x1, 0,, % &quot;ahk_id &quot; Icon%A_Index%
      SendMessage, ( STM_SETIMAGE:=0x172 ), 0x1, hIcon,, % &quot;ahk_id &quot; Icon%A_Index%
      DllCall( &quot;FreeResource&quot;, UInt,hResData )
      GuiControl,,IconT%A_Index%, % W &quot;x&quot; H &quot;-&quot; BPP &quot;b&quot; 
  }
  Loop % 16-Icos {
      Ix := Icos+A_Index
      GuiControl,,IconT%Ix%, -     
      SendMessage, ( STM_SETIMAGE:=0x172 ), 0x1, 0,, % &quot;ahk_id &quot; Icon%Ix%
  }
  DllCall( &quot;FreeResource&quot;, UInt,hResData ), DllCall( &quot;FreeLibrary&quot;, UInt,hModule )
Return

GetResource( hModule, rName, rType, ByRef nSize, ByRef hResData ) {
  hResource := DllCall( &quot;FindResource&quot;, UInt,hModule, UInt,rName, UInt,rType )
  nSize     := DllCall( &quot;SizeofResource&quot;, UInt,hModule, UInt,hResource )
  hResData  := DllCall( &quot;LoadResource&quot;, UInt,hModule, UInt,hResource )
Return DllCall( &quot;LockResource&quot;, UInt, hResData )
}

ExtractIconRes:
  FileSelectFolder, TargetFolder, *%DEFF%, 3, Extract Icons! Where to?
  IfEqual,TargetFolder,, Return
  GoSub, SetFolder
  hModule := DllCall( &quot;LoadLibraryEx&quot;, Str,tFolder &quot;\&quot; File, UInt,0, UInt,0x2 )
  Loop, Parse, IG, |
    {
      FileN := SubStr( &quot;000&quot; A_Index, -3 ) &quot;-&quot; SubStr( &quot;00000&quot; A_LoopField, -4 ) &quot;.ico&quot;
      SB_SetText( (FileN := TargetFolder &quot;\&quot; FileN), 2 ), IconGroup := A_LoopField
      GoSub, WriteIcon
    }
  DllCall( &quot;FreeLibrary&quot;, UInt,hModule ), SB_SetText( IGC &quot; Icons extracted!&quot;, 2 )
  DllCall( &quot;Sleep&quot;, UInt,1000 ), SB_SetText( TargetFolder, 2 )
Return

ExtractIcon:
  LV_GetText( IconGroup, RowNo,1 )
  FileN := SaveIcon( DEFF &quot;\&quot; File &quot;-IG&quot; SubStr( &quot;-00000&quot; IconGroup, -4 ) &quot;.ico&quot; )
  IfEqual,FileN,,Return   
  hModule := DllCall( &quot;LoadLibraryEx&quot;, Str,tFolder &quot;\&quot; File, UInt,0, UInt,0x2 )
  GoSub, WriteIcon
  DllCall( &quot;FreeLibrary&quot;, UInt,hModule ), SB_SetText( FileN, 2 )
Return

WriteIcon:
 hFile := DllCall( &quot;_lcreat&quot;, Str,FileN, UInt,0 )
 sBuff := GetResource( hModule, IconGroup, (RT_GROUP_ICON:=14), nSize, hResData )
 Icons := NumGet( sBuff+0, 4, &quot;UShort&quot; )
 tSize := nSize+( Icons*2 ), VarSetCapacity( tmpBuff,tSize, 0 ), tBuff := &amp;tmpBuff
 CopyData( sBuff, tBuff, 6  ),   sBuff:=sBuff+06,  tBuff:=tBuff+06
 Loop %Icons%
      CopyData( sBuff, tBuff, 14  ),  sBuff:=sBuff+14,  tBuff:=tBuff+16
 DllCall( &quot;FreeResource&quot;, UInt,hResData )
 DllCall( &quot;_lwrite&quot;, UInt,hFile, Str,tmpBuff, UInt,tSize )
 EOF := DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,-0, UInt,2 )
 VarSetCapacity( tmpBuff, 0 )
 DataOffset := DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,18, UInt,0 )

 Loop %Icons% {
      VarSetCapacity( Data,4,0 )
      DllCall( &quot;_lread&quot;, UInt,hFile, Str,Data, UInt,2 ),
      nID := NumGet( Data, 0, &quot;UShort&quot; )
      DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,-2, UInt,1 )
      NumPut( EOF, Data ),  DllCall( &quot;_lwrite&quot;, UInt,hFile, Str,Data, UInt,4 )
      DataOffset := DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,0, UInt,1 )
      sBuff := GetResource( hModule, nID, (RT_ICON:=3), nSize, hResData )   
      DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,0, UInt,2 )         
      DllCall( &quot;_lwrite&quot;, UInt,hFile, UInt,sBuff, UInt,nSize )
      DllCall( &quot;FreeResource&quot;, UInt,hResData )
      EOF := DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,-0, UInt,2 )
      DataOffset := DllCall( &quot;_llseek&quot;, UInt,hFile, UInt,DataOffset+12, UInt,0 )
 } 
 DllCall( &quot;_lclose&quot;, UInt,hFile )
Return

SelectSimpleIcon:
  StringTrimLeft,FNo,A_GuiControl,1
  GuiControlGet, IconT%fNo%
  If ( (IconT := IconT%fNo%) = &quot;-&quot; )
       Return
  SB_SetText(&quot;Press &lt;&quot; KeyName &quot;&gt; to save Icon &quot; IconT  &quot; from Icon Group &quot; IconGroup ,2)
  GuiControl, Enable, Hotkey
  GuiControl, Focus,  Hotkey
  GuiControl,,Hotkey
  SetTimer, DisableHotkey, -5000
Return

DisableHotkey:
  GuiControlGet, Hotkey, Enabled
  If ( Hotkey ) {
  GuiControl,,Hotkey
  GuiControl, Disable, Hotkey
  GuiControl, Focus, LVI
  StatusBarGetText, SbTxt, 2, IconEx
  InStr( SbTxt, &quot;to save Icon&quot;) ? SB_SetText( &quot;&quot;, 2 ) :
  }   
Return 

CreateSimpleIcon:
  SB_SetText( &quot;&quot;, 2 )
  GuiControlGet, Hotkey
  GuiControl, Disable, Hotkey
  IfNotEqual, Hotkey, %KeyName%, Return

  FileN := SaveIcon( Deff &quot;\&quot; File &quot; [&quot; SubStr(&quot;0000&quot; IconGroup, -4 ) &quot;-&quot;
                    . SubStr( &quot;0&quot; FNo,-1) &quot;][ &quot; IconT &quot;].ico&quot; )           
  IfEqual,FileN,, Return     
  hModule := DllCall( &quot;LoadLibraryEx&quot;, Str,tFolder &quot;\&quot; File, UInt,0, UInt,0x2 )
  Buffer := GetResource( hModule, IconGroup, (RT_GROUP_ICON:=14), nSize, hResData )
  tBuff := Buffer+6+((Fno-1)*14), nID := Numget( tBuff+0, 12, &quot;Ushort&quot; )
  VarSetCapacity(Z,10,0), NumPut(1,Z,2,&quot;UChar&quot;), NumPut(1,Z,4,&quot;UChar&quot; ),NumPut(22,Z,6)
  SBuff := GetResource( hModule, nID, (RT_ICON:=3), nSize, hResData )
  hFile := DllCall( &quot;_lcreat&quot;, Str,FileN, UInt,0 )
  DllCall( &quot;_lwrite&quot;, UInt,hFile, Str,Z, UInt,6 )
  DllCall( &quot;_lwrite&quot;, UInt,hFile, UInt,tbuff, UInt,12 )
  DllCall( &quot;_lwrite&quot;, UInt,hFile, UInt,&amp;Z+6, UInt,4 )
  DllCall( &quot;FreeResource&quot;, UInt,hResData )
  Buff := GetResource( hModule, nID, (RT_ICON:=3), nSize, hResData )
  DllCall( &quot;_lwrite&quot;, UInt,hFile, UInt,Buff, UInt,nSize )
  DllCall( &quot;_lclose&quot;, UInt,hFile )
  DllCall( &quot;FreeResource&quot;, UInt,hResData ),  DllCall( &quot;FreeLibrary&quot;, UInt,hModule )
  SB_SetText( FileN, 2 )
Return

FindTarget:
  StatusBarGetText, SB, 2, A
  IfExist, %SB%, Run, %COMSPEC% /c &quot;Explorer /select`, %SB%&quot;,,Hide
Return

SetFolder:
  ControlGetText,tFolder,, ahk_id %hSHAC%
  If ! InStr( FileExist( tFolder ), &quot;D&quot; ) {
    SplitPath, tFolder,, tFolder
    ControlSetText,,% (tFolder:=DllCall(&quot;CharUpperA&quot;,Str,tFolder,Str )), ahk_id %hSHAC%
 }     
Return

SelectFolder:
  GoSub, SetFolder
  FileSelectFolder, nFolder, *%tFolder%, , Select a Resource Folder
  IfEqual,nFolder,,Return
  ControlSetText,,%nFolder%, ahk_id %hSHAC%
  GoSub, SetFolder
  GoSub, UpdateResourceList
Return

CopyData( SPtr, TPtr, nSize ) {
  Return DllCall( &quot;RtlMoveMemory&quot;, UInt,TPtr, UInt,SPtr, UInt,nSize )
}

SaveIcon( Filename, Prompt=&quot;Save Icon As&quot;  ) {
  FileSelectFile, File, 16, %Filename%, %Prompt%, Icon (*.ico)
Return ( File &lt;&gt; &quot;&quot; and SubStr( File, -3 ) &lt;&gt; &quot;.ico&quot; ) ? File &quot;.ico&quot; : File
}

Accelerator:
 IfEqual,A_GuiControl,&amp;File, GuiControl,Focus,LVR
 IfEqual,A_GuiControl,&amp;Icon, GuiControl,Focus,LVI
 IfEqual,A_GuiControl,A&amp;ddress Bar, GuiControl,Focus,tFolder
 IfEqual,A_GuiControl,&amp;Reload,IfExist,%tFolder%\%File%
    {
      FileAppend,%tFolder%\%File%,%A_Temp%\IconEx.tmp
      Reload     
    }
 
Return
 
GuiContextMenu:
  StatusBarGetText, SbTxt, 2, IconEx
  StringTrimLeft, SbTxt,SbTxt, 14
  If ( SubStr( SbTxt, 1,4) = &quot;save&quot; )
     SendInput {%KeyName%}
Return   

GuiClose:
  ExitApp
 
ApplyIconToFolder:
 FileSelectFolder, applyFolder,::{20d04fe0-3aea-1069-a2d8-08002b30309d},0, Apply Folder Icon
 If ( applyFolder=&quot;&quot; OR ErrorLevel )
    Return
 dini := applyFolder &quot;\Desktop.ini&quot;
 IniRead, iconFile, %dini%, .ShellClassInfo, IconFile, %A_Space%
 If ( SubStr(iconFile,1,7 ) == &quot;IconEx_&quot; )
    FileDelete,%applyFolder%\%iconFile%
 iconFile := ( &quot;IconEx_&quot; HashStr( A_Now ) &quot;.ico&quot; ), FileN := applyFolder &quot;\&quot; iconFile
 hModule := DllCall( &quot;LoadLibraryEx&quot;, Str,tFolder &quot;\&quot; File, UInt,0, UInt,0x2 )
 LV_GetText( IconGroup, RowNo,1 )
 GoSub, WriteIcon
 DllCall( &quot;FreeLibrary&quot;, UInt,hModule ), SB_SetText( FileN, 2 )
 IniWrite, %IconFile%, %dini%, .ShellClassInfo, IconFile
 IniWrite, 0         , %dini%, .ShellClassInfo, IconIndex
 FileSetAttrib, +S, %applyFolder%
 FileSetAttrib, +SH, %dini%
 FileSetAttrib, +SH, %FileN%
 ; SHCNE_ASSOCCHANGED := 0x8000000
 DllCall( &quot;Shell32\SHChangeNotify&quot;, UInt,0x8000000, UInt,0x0, UInt,0, UInt,0 )
 Run Properties &quot;%applyFolder%&quot;
Return

HashStr( sStr=&quot;&quot; ) {
 Static hHash=12345678
 DllCall( &quot;shlwapi\UrlHashA&quot;,  Str,sStr, UIntP,dHash, UInt,4 )
 DllCall( &quot;msvcrt.dll\sprintf&quot;, Str,hHash, Str,&quot;%08X&quot;, UInt,dHash )
 Return ( sStr&lt;&gt;&quot;&quot; ) ? hHash :
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-12-04T09:54:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88851#p88851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88850#p88850" />
			<content type="html"><![CDATA[<p>А на код ссылка есть?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-04T09:18:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88850#p88850</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88849#p88849" />
			<content type="html"><![CDATA[<p>Ссылка с англоязычного форума на тему извлечения иконок:<br /><a href="http://www.autohotkey.com/board/topic/28923-crazy-scripting-iconex-v14b-icon-explorer-extractor/">IconEx v1.4b - Обозреватель / извлекатель иконок</a></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-12-04T09:15:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88849#p88849</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88105#p88105" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Какой пример?<br />У меня так работает:</p></blockquote></div><p>Спасибо, так у меня тоже работает. Оказалось, что код скопировался как-то с потерями: все имена функций в dllcall&#039;ах были слеплены вот так &quot;Kernel32.dllGetModuleHandle&quot;, вместо &quot;Kernel32.dll\GetModuleHandle&quot;.<br />Тогда, получается, что этим методом можно получать иконку.<br />Вот только разницы между SMALL и SYSSMALL я не понимаю: на вид они одинаковы.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2014-11-08T09:10:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88105#p88105</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88060#p88060" />
			<content type="html"><![CDATA[<p>У меня всё работает на x64. Конечно, пути к иконкам это не определяет, но даёт возможность получить иконки большого размера, если они есть в наличии.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-11-06T19:00:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88060#p88060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88059#p88059" />
			<content type="html"><![CDATA[<p>Какой пример?<br />У меня так работает:<br /></p><div class="codebox"><pre><code>#NoEnv
SetBatchLines, -1
SHIL := {LARGE: 0x00, SMALL: 0x01, EXTRALARGE: 0x02, SYSSMALL: 0x03, JUMBO: 0x04}
SS_ICON := 0x03
STM_SETICON := 0x0170
Path := &quot;.pdf&quot;
For Size, Value In SHIL {
   If !IsObject(Icon := GetSysImgLstIcon(Path, Size)) {
      MsgBox, 16, Error - %Size%, No icon found for path`r`n%Path%!
      Continue
   }
   Gui, +LastFound
   Gui, Margin, 20, 20
   IW := Icon.W, IH := Icon.H
   Gui, Add, Text, xm, Path:`t%Path%`r`nSize;`t%Size%`r`nWidth:`t%IW%`r`nHeight:`t%IH%
   Gui, Add, Pic, w%IW% h%IH% +%SS_ICON% hwndHSTATIC
   SendMessage, %STM_SETICON%, % Icon.HICON, 0, , ahk_id %HSTATIC%
   Gui, Add, Button, Default gGuiClose, Exit
   Gui, Show, w296, ShellGetIcon
   WinWaitClose
}
ExitApp
GuiClose:
   Gui, Destroy
Return
GuiEscape:
ExitApp




GetSysImgLstIcon(Path, Size := &quot;SYSSMALL&quot;, Overlay := &quot;&quot;) {
   Static AW := A_IsUnicode ? &quot;W&quot; : &quot;A&quot;
   Static cbSFI := A_PtrSize + 8 + (340 &lt;&lt; !!A_IsUnicode)
   Static FILE_ATTRIBUTE_NORMAL := 0x80
   Static IID_IIL_Str := &quot;{46EB5926-582E-4017-9FDF-E8998DAA0950}&quot;
   Static SHGFI := {SYSICONINDEX: 0x04000, USEFILEATTRIBUTES: 0x0010}
   Static SHGIOI := {SHARE: 0x0FFFFFFF, LINK: 0x0FFFFFFE, SLOWFILE: 0x0FFFFFFD, DEFAULT: 0x0FFFFFFC}
   Static SHIL := {LARGE: 0x00, SMALL: 0x01, EXTRALARGE: 0x02, SYSSMALL: 0x03, JUMBO: 0x04}
   If !SHIL.HasKey(Size)
      Return False
   VarSetCapacity(IID_IIL, 16, 0) ; IID
   If DllCall(&quot;Ole32.dll\IIDFromString&quot;, &quot;WStr&quot;, IID_IIL_Str, &quot;Ptr&quot;, &amp;IID_IIL, &quot;UInt&quot;)
      Return False
   HMOD := DllCall(&quot;Kernel32.dll\GetModuleHandle&quot;, &quot;Str&quot;, &quot;shell32.dll&quot;, &quot;UPtr&quot;)
   FileIconInit := DllCall(&quot;Kernel32.dll\GetProcAddress&quot;, &quot;Ptr&quot;, HMOD, &quot;Ptr&quot;, 660, &quot;UPtr&quot;)
   DllCall(FileIconInit, &quot;UInt&quot;, True, &quot;UInt&quot;)
   VarSetCapacity(SFI, cbSFI, 0) ; SHFILEINFO
   ; pure extensions need special handling
   Flags := SHGFI.SYSICONINDEX | (SubStr(Path, 1, 1) = &quot;.&quot; ? SHGFI.USEFILEATTRIBUTES : 0x0)
   If !DllCall(&quot;Shell32.dll\SHGetFileInfo&quot; . AW, &quot;Str&quot;, Path, &quot;UInt&quot;, 0x80, &quot;Ptr&quot;, &amp;SFI, &quot;UInt&quot;, cbSFI, &quot;UInt&quot;, Flags, &quot;UPtr&quot;)
      Return False
   IconIndex := NumGet(SFI, A_PtrSize, &quot;Int&quot;)
   If DllCall(&quot;Shell32.dll\SHGetImageList&quot;, &quot;Int&quot;, SHIL[Size], &quot;Ptr&quot;, &amp;IID_IIL, &quot;PtrP&quot;, IIL, &quot;UInt&quot;)
      Return False
   Flags := 0x0020 ; ILD_IMAGE
   ; overlays need a special handling
   If SHGIOI.HasKey(Overlay)
   &amp;&amp; (IOV := DllCall(&quot;Shell32.dll\SHGetIconOverlayIndex&quot;, &quot;Ptr&quot;, 0, &quot;UInt&quot;, SHGIOI[Overlay], &quot;Int&quot;)) &gt;= 0
      Flags |= IOV &lt;&lt; 8
   DllCall(&quot;Comctl32.dll\ImageList_GetIconSize&quot;, &quot;Ptr&quot;, IIL, &quot;IntP&quot;, CX, &quot;IntP&quot;, CY, &quot;UInt&quot;)
   HICON := DllCall(&quot;Comctl32.dll\ImageList_GetIcon&quot;, &quot;Ptr&quot;, IIL, &quot;Int&quot;, IconIndex, &quot;UInt&quot;, Flags, &quot;UPtr&quot;)
   Return {HICON: HICON, W: CX, H: CY}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-11-06T18:58:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88059#p88059</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88058#p88058" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>А этот код не прояснит ситуацию?<br /><a href="http://ahkscript.org/boards/viewtopic.php?f=6&amp;t=1004">http://ahkscript.org/boards/viewtopic.p … amp;t=1004</a></p></blockquote></div><p>А у вас он работает? У меня первый пример из темы выдаёт ошибку &#039;Error - %Size%, No icon found for path`r`n%Path%!&#039; а второй показывает гуй с отсутствующими lv.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2014-11-06T18:47:55Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88058#p88058</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: как узнать путь к иконке используемой файлом?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=88055#p88055" />
			<content type="html"><![CDATA[<p>Не думаю.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-11-06T15:46:33Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=88055#p88055</id>
		</entry>
</feed>
