<?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=17968&amp;type=atom" />
	<updated>2023-10-08T12:04:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17968</id>
		<entry>
			<title type="html"><![CDATA[AHK: Закрепить приложение на панели задач с недокументированным апи]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=159313#p159313" />
			<content type="html"><![CDATA[<p><a href="https://geelaw.blog/entries/msedge-pins">https://geelaw.blog/entries/msedge-pins</a><br /><a href="https://github.com/vhanla/W1nDro1d/blob/main/TaskbarPinner.pas">https://github.com/vhanla/W1nDro1d/blob … Pinner.pas</a><br /></p><div class="codebox"><pre><code>msgbox % GetAllPinned()
pin(&quot;C:\Windows\System32\Notepad.exe&quot;)
msgbox pinned
unpin(&quot;C:\Windows\System32\Notepad.exe&quot;)
msgbox unpinned

pin(app)   ; https://geelaw.blog/entries/msedge-pins https://github.com/vhanla/W1nDro1d/blob/main/TaskbarPinner.pas
{
   static oIPinnedList3 := TaskbandPin_Init()
   static FOLDERID_System := SHGetKnownFolderPath(&quot;{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}&quot;)
   if A_Is64bitOS and (A_PtrSize = 4) and InStr(app, FOLDERID_System)
   {
      msgbox For applications in %FOLDERID_System% need to run script with ahk64.
      exitapp
   }
   pidl := DllCall(&quot;Shell32.dll\ILCreateFromPathW&quot;, &quot;wstr&quot;, app, &quot;ptr&quot;)
   if DllCall(NumGet(NumGet(oIPinnedList3+0)+9*A_PtrSize), &quot;ptr&quot;, oIPinnedList3, &quot;ptr&quot;, pidl)  ; IsPinned
      DllCall(NumGet(NumGet(oIPinnedList3+0)+16*A_PtrSize), &quot;ptr&quot;, oIPinnedList3, &quot;ptr&quot;, 0, &quot;ptr&quot;, pidl, &quot;int&quot;, PLMC_EXPLORER := 4)   ; modify
   DllCall(&quot;Shell32.dll\ILFree&quot;, &quot;ptr&quot;, pidl)
}

unpin(app)
{
   static oIPinnedList3 := TaskbandPin_Init()
   static FOLDERID_System := SHGetKnownFolderPath(&quot;{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}&quot;)
   if A_Is64bitOS and (A_PtrSize = 4) and InStr(app, FOLDERID_System)
   {
      msgbox For applications in %FOLDERID_System% need to run script with ahk64.
      exitapp
   }
   pidl := DllCall(&quot;Shell32.dll\ILCreateFromPathW&quot;, &quot;wstr&quot;, app, &quot;ptr&quot;)
   if !DllCall(NumGet(NumGet(oIPinnedList3+0)+9*A_PtrSize), &quot;ptr&quot;, oIPinnedList3, &quot;ptr&quot;, pidl)  ; IsPinned
      DllCall(NumGet(NumGet(oIPinnedList3+0)+16*A_PtrSize), &quot;ptr&quot;, oIPinnedList3, &quot;ptr&quot;, pidl, &quot;ptr&quot;, 0, &quot;int&quot;, PLMC_EXPLORER := 4)   ; modify
   DllCall(&quot;Shell32.dll\ILFree&quot;, &quot;ptr&quot;, pidl)
}

GetAllPinned()
{
   static oIPinnedList3 := TaskbandPin_Init()
   DllCall(NumGet(NumGet(oIPinnedList3+0)+3*A_PtrSize), &quot;ptr&quot;, oIPinnedList3, &quot;ptr*&quot;, IEnumFullIDList)  ; EnumObjects
   DllCall(NumGet(NumGet(IEnumFullIDList+0)+5*A_PtrSize), &quot;ptr&quot;, IEnumFullIDList)   ; reset
   loop
   {
      if DllCall(NumGet(NumGet(IEnumFullIDList+0)+3*A_PtrSize), &quot;ptr&quot;, IEnumFullIDList, &quot;uint&quot;, 1, &quot;ptr*&quot;, pidl, &quot;uint*&quot;, null)   ; next
         break
      VarSetCapacity(FilePath, 512, 0)
      DllCall(&quot;Shell32.dll\SHGetPathFromIDListW&quot;, &quot;ptr&quot;, pidl, &quot;str&quot;, FilePath)
      FilePaths .= FilePath &quot;`n&quot;
      DllCall(&quot;Ole32.dll\CoTaskMemFree&quot;, &quot;ptr&quot;, pidl)
   }
   return FilePaths
}

TaskbandPin_Init()
{
   static oIPinnedList3
   if !oIPinnedList3
      oIPinnedList3 := ComObjCreate(CLSID_TaskbandPin := &quot;{90AA3A4E-1CBA-4233-B8BB-535773D48449}&quot;, IPinnedList3 := &quot;{0DD79AE2-D156-45D4-9EEB-3B549769E940}&quot;)
   return oIPinnedList3
}

SHGetKnownFolderPath(FOLDERID, KF_FLAG:=0) {                  ;   By SKAN on D356 @ tiny.cc/t-75602 
Local CLSID, pPath:=&quot;&quot;                                        ; Thanks teadrinker @ tiny.cc/p286094
Return Format(&quot;{4:}&quot;, VarSetCapacity(CLSID, 16, 0)
     , DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;Str&quot;,FOLDERID, &quot;Ptr&quot;,&amp;CLSID)
     , DllCall(&quot;shell32\SHGetKnownFolderPath&quot;, &quot;Ptr&quot;,&amp;CLSID, &quot;UInt&quot;,KF_FLAG, &quot;Ptr&quot;,0, &quot;PtrP&quot;,pPath)
     , StrGet(pPath, &quot;utf-16&quot;)
     , DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;Ptr&quot;,pPath))
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?pid=159314">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-10-08T12:04:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=159313#p159313</id>
		</entry>
</feed>
