<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11348&amp;type=atom" />
	<updated>2017-09-26T18:08:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11348</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119601#p119601" />
			<content type="html"><![CDATA[<p>Сделайте это сами.<br />Перебор пунктов меню и их сравнение с вашим идет в коде из 33 поста.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-26T18:08:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119601#p119601</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119600#p119600" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, добавьте, пожалуйста, чувствительность к названию выбираемого пункта, т.к. при смене его расположения в списке также меняется и название, а именно хоткей. Или же не брать в название все, что идет после большого пробела (Tab).</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-26T17:45:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119600#p119600</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119599#p119599" />
			<content type="html"><![CDATA[<p>А я не имел в виду именно эту функцию, а функции вообще.<br />Если вы поймете как они работают, то и понимать чужие скрипты будет проще.<br />Тем более справка имеется на русском.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-26T13:57:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119599#p119599</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119598#p119598" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, ф-ия сложная мне для понимания.<br />Да, я в какой-то момент вернул ф-ию в первоначальный вид, сам того не заметив. Теперь все работает. Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-26T13:35:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119598#p119598</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119597#p119597" />
			<content type="html"><![CDATA[<p><strong>becauseim</strong>, почитайте про функции, как они работают и что&nbsp; возвращают.<br />Потом попробуйте понять алгоритм скрипта.<br />А не работает у вас, потому что вы не сделали то, что я написал в 33 посте.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-26T13:16:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119597#p119597</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119596#p119596" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, получаю пустое окно:<br /></p><div class="codebox"><pre><code>MsgBox, % StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;)

GetMenuItemCheckState(hWin, path)
{
	static MIIM_STRING := 0x40, MIIM_STATE := 0x1
	Loop, parse, path, |
	{
		hMenu := A_Index = 1 ? DllCall(&quot;GetMenu&quot;, Ptr, hWin, Ptr) : DllCall(&quot;GetSubMenu&quot;, Ptr, hMenu, Int, SubMenuPos)
		SubMenuPos := &quot;&quot;
Loop % DllCall(&quot;GetMenuItemCount&quot;, Ptr, hMenu)
   if StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;) = A_LoopField &amp;&amp; SubMenuPos := A_Index - 1
      break
	  if (SubMenuPos = &quot;&quot;)  {
			MsgBox, % &quot;Не найден пункт меню &quot;&quot;&quot; A_LoopField &quot;&quot;&quot; по пути &quot;&quot;&quot; path &quot;&quot;&quot;&quot;
			Return
		}
	}
	SendMessage, 0x117, hMenu, SubMenuPos,, ahk_id %hWin% ; WM_INITMENUPOPUP
	Return GetMenuItemInfo(hMenu, SubMenuPos, MIIM_STATE) &amp; 0x8 ? 1 : 0
}
	
GetMenuItemInfo(hMenu, ItemNumber, TypeOfInfo)
{
	static MIIM_STRING := 0x40, MIIM_STATE := 0x1
	VarSetCapacity(MENUITEMINFO, size := 4*4 + A_PtrSize*8, 0)
	NumPut(size, MENUITEMINFO)
	NumPut(TypeOfInfo, MENUITEMINFO, 4)
	DllCall(&quot;GetMenuItemInfo&quot;, Ptr, hMenu, UInt, ItemNumber, UInt, 1, Ptr, &amp;MENUITEMINFO)
	
	if (TypeOfInfo &amp; MIIM_STRING)  {
		nChars := NumGet(MENUITEMINFO, 4*4 + A_PtrSize*6, &quot;UInt&quot;) + 1
		if (nChars &gt; 1)  {
			VarSetCapacity(buff, nChars * (A_IsUnicode ? 2 : 1), 0)
			NumPut(&amp;buff, MENUITEMINFO, 4*4 + A_PtrSize*5)
			NumPut(nChars, MENUITEMINFO, 4*4 + A_PtrSize*6)
			DllCall(&quot;GetMenuItemInfo&quot;, Ptr, hMenu, UInt, A_Index - 1, UInt, 1, Ptr, &amp;MENUITEMINFO)
			info := StrGet(&amp;buff)
		}
	}
	if (TypeOfInfo &amp; MIIM_STATE)
		info := NumGet(MENUITEMINFO, 4*3, &quot;Int&quot;)
	Return info
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-26T13:11:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119596#p119596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119595#p119595" />
			<content type="html"><![CDATA[<p>У меня работает.<br />Возможно вы не то исправили.<br />StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;) - это обращение к функции.<br />Что она возвращает можно посмотреть с помощью msgbox.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-26T13:02:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119595#p119595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119594#p119594" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, не понял на счет проверки StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;).<br />У Вас так работает?<br /></p><div class="codebox"><pre><code>MsgBox, % GetMenuItemCheckState(WinExist(&quot;ahk_class Premiere Pro&quot;), &quot;Window|Workspaces|Import Workspace from Projects&quot;)
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-26T12:32:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119594#p119594</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119593#p119593" />
			<content type="html"><![CDATA[<p>Проверяйте значение StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;)<br />Может не так вписали название пункта.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-26T01:32:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119593#p119593</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119592#p119592" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, заменил, но подменю по-прежнему не работает:<br /></p><div class="codebox"><pre><code>MsgBox, % GetMenuItemCheckState(WinExist(&quot;ahk_class Premiere Pro&quot;), &quot;Window|Workspaces|Timeline	Alt+Shift+3&quot;)</code></pre></div><p>Так работает:<br /></p><div class="codebox"><pre><code>MsgBox, % GetMenuItemCheckState(WinExist(&quot;ahk_class Premiere Pro&quot;), &quot;Window|Lumetri Color	Shift+9&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-25T22:22:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119592#p119592</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119572#p119572" />
			<content type="html"><![CDATA[<p>Да, у <strong>teadrinkerа</strong> в функции ошибка.<br />Надо это<br /></p><div class="codebox"><pre><code>Loop % DllCall(&quot;GetMenuItemCount&quot;, Ptr, hMenu)
   if StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;) = A_LoopField &amp;&amp; SubMenuPos := A_Index - 1
      break</code></pre></div><p>заменить на<br /></p><div class="codebox"><pre><code>Loop % DllCall(&quot;GetMenuItemCount&quot;, Ptr, hMenu)
{
   if StrReplace(GetMenuItemInfo(hMenu, A_Index - 1, MIIM_STRING), &quot;&amp;&quot;) = A_LoopField
   {
      SubMenuPos := A_Index - 1
      break
   }
}</code></pre></div><div class="quotebox"><cite>becauseim пишет:</cite><blockquote><p>Думал, можно как-то задать условие, что если последний параметр не задан, то заменить в конце ф-ии SubMenu2 на SubMenu.</p></blockquote></div><p>Можно и так. Делайте.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-25T11:52:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119572#p119572</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119571#p119571" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, спасибо, работает! Но у меня не работает подменю. Ввожу так:<br /></p><div class="codebox"><pre><code>MsgBox, % GetMenuItemCheckState(WinExist(&quot;ahk_class Premiere Pro&quot;), &quot;Window|Workspaces|Timeline	Alt+Shift+3&quot;)
</code></pre></div><div class="quotebox"><blockquote><p>Передавайте номера всех меню в одном параметре через какой-нибудь разделитель, а в функции их парсьте.</p></blockquote></div><p>Думал, можно как-то задать условие, что если последний параметр не задан, то заменить в конце ф-ии <em>SubMenu2 </em>на <em>SubMenu</em>.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-25T11:04:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119571#p119571</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119566#p119566" />
			<content type="html"><![CDATA[<p>Там надо вставить<br /></p><div class="codebox"><pre><code>SendMessage, 0x117, hMenu, SubMenuPos,, ahk_id %hWin% ; WM_INITMENUPOPUP</code></pre></div><p>перед<br /></p><div class="codebox"><pre><code>Return GetMenuItemInfo(hMenu, SubMenuPos, MIIM_STATE) &amp; 0x8 ? 1 : 0</code></pre></div><div class="quotebox"><cite>becauseim пишет:</cite><blockquote><p>И как же их объединить?</p></blockquote></div><p>Передавайте номера всех меню в одном параметре через какой-нибудь разделитель, а в функции их парсьте.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-09-25T10:44:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119566#p119566</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119565#p119565" />
			<content type="html"><![CDATA[<p>В коде из четвертого поста не нашел упоминание <em>WM_INITMENU</em>, для замены на <em>WM_INITMENUPOPUP</em>.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-25T10:40:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119565#p119565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: WinMenuSelectItem Проверка состояния переключателя пункта меню]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119564#p119564" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, спасибо! И как же их объединить?</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-09-25T10:28:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119564#p119564</id>
		</entry>
</feed>
