<?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=12649</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12649&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Поиск заданного пункта в панели меню».]]></description>
		<lastBuildDate>Tue, 02 May 2017 12:26:15 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115609#p115609</link>
			<description><![CDATA[<p>Уверен, что это вы уже сами сможете сделать.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 02 May 2017 12:26:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115609#p115609</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115606#p115606</link>
			<description><![CDATA[<p><strong>Malcev</strong>, да, выдает порядковый номер расположения пункта начиная с нуля. Спасибо! Только я еще не учел то, что и имя пункта меняется в зависимости от его положения в списке, а именно, горячая клавиша. Т.е. необходимо добавить чувствительность к имени пункта, чтобы было достаточно одного слова.</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Tue, 02 May 2017 11:38:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115606#p115606</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115599#p115599</link>
			<description><![CDATA[<p>Так?<br /></p><div class="codebox"><pre><code>msgbox % GetMenuNumber(&quot;ahk_class Premiere Pro&quot;, 6, 0, &quot;Reset to Saved Layout	Alt+Shift+0&quot;)

GetMenuNumber(program, Number1, Number2, Name)
{
   Hwnd := WinExist(program)
   hMenu := DllCall(&quot;GetMenu&quot;, Ptr, Hwnd)
   loop 2
      hMenu := DllCall(&quot;GetSubMenu&quot;, Ptr, hMenu, Int, Number%A_Index%)
   count := DllCall(&quot;GetMenuItemCount&quot;, Ptr, hMenu)
   loop % count
   {
      VarSetCapacity(MENUITEMINFO, size := 4*4 + A_PtrSize*8, 0)
      NumPut(size, MENUITEMINFO)
      NumPut(0x40, &amp;MENUITEMINFO + 4)   ;  MIIM_STRING := 0x40
      DllCall(&quot;GetMenuItemInfo&quot;, Ptr, hMenu, UInt, A_Index - 1, UInt, true, Ptr, &amp;MENUITEMINFO)
      TextLength := NumGet(&amp;MENUITEMINFO + 4*4 + A_PtrSize*6, &quot;UInt&quot;)
      VarSetCapacity(TextBuff, TextLength * (A_IsUnicode ? 2 : 1), 0)
      NumPut(&amp;TextBuff, &amp;MENUITEMINFO + 4*4 + A_PtrSize*5)
      NumPut(++TextLength, &amp;MENUITEMINFO + 4*4 + A_PtrSize*6)
      DllCall(&quot;GetMenuItemInfo&quot;, Ptr, hMenu, UInt, A_Index - 1, UInt, true, Ptr, &amp;MENUITEMINFO)
      InfoString := StrGet(&amp;TextBuff)
      if (InfoString = name)
         return A_Index - 1
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 02 May 2017 01:15:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115599#p115599</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115594#p115594</link>
			<description><![CDATA[<p><strong>serzh82saratov</strong>, спасибо! Но у меня, к соожалению, не получается сделать условие.<br />Но больше хотелось бы применить результат к уже имеющейся форме из первого поста. Т.е. присвоить полученный порядковый номер значению <em>ItemNumber</em> (последний параметр функции):<br /></p><div class="codebox"><pre><code>
Path := [&quot;Формат&quot;, &quot;Перенос по словам&quot;]
; ...узнаем, что пункт &quot;Перенос по словам&quot; значится под нулевым порядковым номером
WordWrap := SelectMenu(&quot;ahk_class Notepad&quot;, 2, 0)
</code></pre></div><p>Еще необходима проверка в т.ч. подпунктов меню (в данном случае <em>Timeline</em>):<br /><span class="postimg"><img src="http://puu.sh/vClAS/e356d9ad18.png" alt="http://puu.sh/vClAS/e356d9ad18.png" /></span></p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Mon, 01 May 2017 19:06:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115594#p115594</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115583#p115583</link>
			<description><![CDATA[<p>Если я понял задачу, то так можно по имени, индексу или вперемешку.<br /></p><div class="codebox"><pre><code>
#SingleInstance Force
#NoEnv

; Path := [&quot;3&amp;&quot;, &quot;1&amp;&quot;]     ;	разделители тоже в счёт
Path := [&quot;Формат&quot;, &quot;Перенос по словам&quot;]
hWnd := WinExist(&quot;ahk_class Notepad ahk_exe notepad.exe&quot;)
MsgBox % GetItemStateMenu(Path, hWnd)
Return 

GetItemStateMenu(Path, hWnd) {
	Static MF_BYPOSITION := 0x400, States := {&quot;MF_CHECKED&quot;:0x00000008, &quot;MF_DISABLED&quot;:0x00000002, &quot;MF_GRAYED&quot;:0x00000001}
	If !hWnd
		Return &quot;Окно не найдено&quot;
	hMenu := DllCall(&quot;GetMenu&quot;, Ptr, Hwnd)
	p := GetItemMenu(hMenu, Path)
	If (State := DllCall(&quot;GetMenuState&quot;, &quot;Ptr&quot;, p.hMenu, &quot;UInt&quot;, p.idx, &quot;UInt&quot;, MF_BYPOSITION)) = -1
		Return &quot;Пункт не найден&quot;
	For k, v in States
		If (State &amp; v)
			Return k
	Return &quot;MF_ENABLED&quot;
}

GetItemMenu(hMenu, Path, Key = 1) {
	Static MF_BYPOSITION := 0x400
	Item := Path[Key]
	Loop, % DllCall(&quot;GetMenuItemCount&quot;, &quot;Ptr&quot;, hMenu)
	{
		If (Item ~= &quot;^\d+&amp;$&quot;)
		{
			idx := SubStr(Item, 1, -1) - 1 
			If (Key &lt; Path.MaxIndex())
				Return GetItemMenu(DllCall(&quot;GetSubMenu&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, idx), Path, Key + 1)
			Return {hMenu:hMenu,idx:idx}
		}
		Else
		{
			idx := A_Index - 1
			idn := DllCall(&quot;GetMenuItemID&quot;, &quot;Ptr&quot;, hMenu, &quot;int&quot;, idx)
			nSize++ := DllCall(&quot;GetMenuString&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, idx, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, MF_BYPOSITION)
			nSize := (nSize * (A_IsUnicode ? 2 : 1))
			VarSetCapacity(sString, nSize)
			DllCall(&quot;GetMenuString&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, idx, &quot;Str&quot;, sString, &quot;Uint&quot;, nSize, &quot;Uint&quot;, MF_BYPOSITION)   ; MF_BYPOSITION
			StringReplace, String, sString, &amp;, , 1
			If (Item != String)
				Continue
			If (Key &lt; Path.MaxIndex())
				Return GetItemMenu(DllCall(&quot;GetSubMenu&quot;, &quot;Ptr&quot;, hMenu, &quot;Uint&quot;, idx), Path, Key + 1)
			Return {hMenu:hMenu,idx:idx}
		}
	}
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 01 May 2017 14:52:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115583#p115583</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Поиск заданного пункта в панели меню]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=115579#p115579</link>
			<description><![CDATA[<p>Благодаря пользователю <strong>Malcev</strong>, использую условие на основе проверки активности заданного пункта меню:<br /></p><div class="codebox"><pre><code>
WordWrap := SelectMenu(&quot;ahk_class Notepad&quot;, 2, 0)

if WordWrap = 8
	MsgBox Word Wrap is Active!
else
	MsgBox Word Wrap is not Active!
return

SelectMenu(program, SubMenuNumber, ItemNumber){
	Hwnd := WinExist(program)
	MainMenu := DllCall(&quot;GetMenu&quot;, UInt, Hwnd)
	SubMenu := DllCall(&quot;GetSubMenu&quot;, UInt, MainMenu, Int, SubMenuNumber)
	SendMessage, 0x117, SubMenu, ItemNumber,, ahk_id %Hwnd% ; WM_INITMENUPOPUP
	return DllCall(&quot;GetMenuState&quot;, UInt, SubMenu, UInt, ItemNumber, UInt, 0x400)
}
</code></pre></div><p>В программе, в которой я работаю, такой пункт имеет свойство перемещаться в порядковом расположении.<br />Необходимо, чтобы при запуске сценария, заданный пункт проверялся на порядковое расположение в подменю. Т.е. на основе данного примера, производился поиск пункта <em>Word Wrap </em> не по всей панели меню, а для ускорения поиска, внутри меню <em>Format</em>, после чего ему присваивался <em>ItemNumber</em>. В сети нашел <a href="https://gist.github.com/Lexikos/5107556">menu-search.ahk</a>, но не знаю, как его использовать. Помогите, пожалуйста, реализовать такой поиск.</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Mon, 01 May 2017 12:38:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=115579#p115579</guid>
		</item>
	</channel>
</rss>
