<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Конекстное меню]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12242</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12242&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Конекстное меню».]]></description>
		<lastBuildDate>Wed, 21 Dec 2016 21:23:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: Конекстное меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109989#p109989</link>
			<description><![CDATA[<p>Необходимо скопировать публичную ссылку (Yandex.Disk) заданного файла посредством сценария. Нашел сценарий, позволяющий вызвать контекстное меню. Но с его помощью не получается вызвать конкретный пункт открываемого списка меню. Отправление клавиши &quot;Y&quot; почему-то не помогает. Она отправляется мимо контекстного меню.<br /></p><div class="codebox"><pre><code>
#Include, ShellContextMenu.ahk

DetectHiddenWindows, On
DetectHiddenText, On

ShellContextMenu(&quot;D:\Clouds\Yandex\file.mp4&quot;)
Sleep, 200
Send, {y}
return</code></pre></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;ShellContextMenu.ahk</div><div class="fancy_spoiler"><div class="codebox"><pre><code>ShellContextMenu( sPath, win_hwnd = 0 )
{
   if ( !sPath  )
      return
   if !win_hwnd
   {
      Gui,SHELL_CONTEXT:New, +hwndwin_hwnd
      Gui,Show
   }
   
   If sPath Is Not Integer
      DllCall(&quot;shell32\SHParseDisplayName&quot;, &quot;Wstr&quot;, sPath, &quot;Ptr&quot;, 0, &quot;Ptr*&quot;, pidl, &quot;Uint&quot;, 0, &quot;Uint*&quot;, 0)
      ;This function is the preferred method to convert a string to a pointer to an item identifier list (PIDL).
   else
      DllCall(&quot;shell32\SHGetFolderLocation&quot;, &quot;Ptr&quot;, 0, &quot;int&quot;, sPath, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 0, &quot;Ptr*&quot;, pidl)
   DllCall(&quot;shell32\SHBindToParent&quot;, &quot;Ptr&quot;, pidl, &quot;Ptr&quot;, GUID4String(IID_IShellFolder,&quot;{000214E6-0000-0000-C000-000000000046}&quot;), &quot;Ptr*&quot;, pIShellFolder, &quot;Ptr*&quot;, pidlChild)
   ;IShellFolder-&gt;GetUIObjectOf
   DllCall(VTable(pIShellFolder, 10), &quot;Ptr&quot;, pIShellFolder, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 1, &quot;Ptr*&quot;, pidlChild, &quot;Ptr&quot;, GUID4String(IID_IContextMenu,&quot;{000214E4-0000-0000-C000-000000000046}&quot;), &quot;Ptr&quot;, 0, &quot;Ptr*&quot;, pIContextMenu)
   ObjRelease(pIShellFolder)
   CoTaskMemFree(pidl)
   
   hMenu := DllCall(&quot;CreatePopupMenu&quot;)
   ;IContextMenu-&gt;QueryContextMenu
   ;http://msdn.microsoft.com/en-us/library/bb776097%28v=VS.85%29.aspx
   DllCall(VTable(pIContextMenu, 3), &quot;Ptr&quot;, pIContextMenu, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, 0, &quot;Uint&quot;, 3, &quot;Uint&quot;, 0x7FFF, &quot;Uint&quot;, 0x100)   ;CMF_EXTENDEDVERBS
   ComObjError(0)
      global pIContextMenu2 := ComObjQuery(pIContextMenu, IID_IContextMenu2:=&quot;{000214F4-0000-0000-C000-000000000046}&quot;)
      global pIContextMenu3 := ComObjQuery(pIContextMenu, IID_IContextMenu3:=&quot;{BCFCE0A0-EC17-11D0-8D10-00A0C90F2719}&quot;)
   e := A_LastError ;GetLastError()
   ComObjError(1)
   if (e != 0)
      goTo, StopContextMenu
   Global   WPOld:= DllCall(&quot;SetWindowLongPtr&quot;, &quot;Ptr&quot;, win_hwnd, &quot;int&quot;,-4, &quot;Ptr&quot;,RegisterCallback(&quot;WindowProc&quot;),&quot;UPtr&quot;)
   DllCall(&quot;GetCursorPos&quot;, &quot;int64*&quot;, pt)
   DllCall(&quot;InsertMenu&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0x0400|0x800, &quot;Ptr&quot;, 2, &quot;Ptr&quot;, 0)
   DllCall(&quot;InsertMenu&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0x0400|0x002, &quot;Ptr&quot;, 1, &quot;Ptr&quot;, &amp;sPath)

   idn := DllCall(&quot;TrackPopupMenuEx&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, 0x0100|0x0001, &quot;int&quot;, pt &lt;&lt; 32 &gt;&gt; 32, &quot;int&quot;, pt &gt;&gt; 32, &quot;Ptr&quot;, win_hwnd, &quot;Uint&quot;, 0)

   /*
   typedef struct _CMINVOKECOMMANDINFOEX {
   DWORD   cbSize;          0
   DWORD   fMask;           4
   HWND    hwnd;            8
   LPCSTR  lpVerb;          8+A_PtrSize
   LPCSTR  lpParameters;    8+2*A_PtrSize
   LPCSTR  lpDirectory;     8+3*A_PtrSize
   int     nShow;           8+4*A_PtrSize
   DWORD   dwHotKey;        12+4*A_PtrSize
   HANDLE  hIcon;           16+4*A_PtrSize
   LPCSTR  lpTitle;         16+5*A_PtrSize
   LPCWSTR lpVerbW;         16+6*A_PtrSize
   LPCWSTR lpParametersW;   16+7*A_PtrSize
   LPCWSTR lpDirectoryW;    16+8*A_PtrSize
   LPCWSTR lpTitleW;        16+9*A_PtrSize
   POINT   ptInvoke;        16+10*A_PtrSize
   } CMINVOKECOMMANDINFOEX, *LPCMINVOKECOMMANDINFOEX;
   http://msdn.microsoft.com/en-us/library/bb773217%28v=VS.85%29.aspx
   */
   struct_size  :=  16+11*A_PtrSize
   VarSetCapacity(pici,struct_size,0)
   NumPut(struct_size,pici,0,&quot;Uint&quot;)         ;cbSize
   NumPut(0x4000|0x20000000|0x00100000,pici,4,&quot;Uint&quot;)   ;fMask
   NumPut(win_hwnd,pici,8,&quot;UPtr&quot;)       ;hwnd
   NumPut(1,pici,8+4*A_PtrSize,&quot;Uint&quot;)       ;nShow
   NumPut(idn-3,pici,8+A_PtrSize,&quot;UPtr&quot;)     ;lpVerb
   NumPut(idn-3,pici,16+6*A_PtrSize,&quot;UPtr&quot;)  ;lpVerbW
   NumPut(pt,pici,16+10*A_PtrSize,&quot;Uptr&quot;)    ;ptInvoke
   
   DllCall(VTable(pIContextMenu, 4), &quot;Ptr&quot;, pIContextMenu, &quot;Ptr&quot;, &amp;pici)   ; InvokeCommand

   DllCall(&quot;GlobalFree&quot;, &quot;Ptr&quot;, DllCall(&quot;SetWindowLongPtr&quot;, &quot;Ptr&quot;, win_hwnd, &quot;int&quot;, -4, &quot;Ptr&quot;, WPOld,&quot;UPtr&quot;))
   DllCall(&quot;DestroyMenu&quot;, &quot;Ptr&quot;, hMenu)
StopContextMenu:
   ObjRelease(pIContextMenu3)
   ObjRelease(pIContextMenu2)
   ObjRelease(pIContextMenu)
   pIContextMenu2:=pIContextMenu3:=WPOld:=0
   Gui,SHELL_CONTEXT:Destroy
   return idn
}
WindowProc(hWnd, nMsg, wParam, lParam)
{
   Global   pIContextMenu2, pIContextMenu3, WPOld
   If   pIContextMenu3
   {    ;IContextMenu3-&gt;HandleMenuMsg2
      If   !DllCall(VTable(pIContextMenu3, 7), &quot;Ptr&quot;, pIContextMenu3, &quot;Uint&quot;, nMsg, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam, &quot;Ptr*&quot;, lResult)
         Return   lResult
   }
   Else If   pIContextMenu2
   {    ;IContextMenu2-&gt;HandleMenuMsg
      If   !DllCall(VTable(pIContextMenu2, 6), &quot;Ptr&quot;, pIContextMenu2, &quot;Uint&quot;, nMsg, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam)
         Return   0
   }
   Return   DllCall(&quot;user32.dll\CallWindowProcW&quot;, &quot;Ptr&quot;, WPOld, &quot;Ptr&quot;, hWnd, &quot;Uint&quot;, nMsg, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam)
}
VTable(ppv, idx)
{
   Return   NumGet(NumGet(1*ppv)+A_PtrSize*idx)
}
GUID4String(ByRef CLSID, String)
{
   VarSetCapacity(CLSID, 16,0)
   return DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;wstr&quot;, String, &quot;Ptr&quot;, &amp;CLSID) &gt;= 0 ? &amp;CLSID : &quot;&quot;
}
CoTaskMemFree(pv)
{
   Return   DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;Ptr&quot;, pv)
}</code></pre></div></div></div><p>А <a href="http://forum.script-coding.com/viewtopic.php?pid=57173#p57173">этот</a> сценарий отлично вызывает заданный пункт меню, но для выделенных файлов в проводнике. Помогите, пожалуйста, совместить эти сценарии так, чтобы вызывался необходимый пункт контекстного меню заданного файла. Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Wed, 21 Dec 2016 21:23:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109989#p109989</guid>
		</item>
	</channel>
</rss>
