<?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=12215&amp;type=atom" />
	<updated>2016-12-12T12:39:33Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12215</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109797#p109797" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>becauseim пишет:</cite><blockquote><p>в справке не нашел примера</p></blockquote></div><p> Поищите в англоязычной по слову &quot;Array&quot;.</p><p>Например так.<br /></p><div class="codebox"><pre><code>myItems := [&quot;Item1&quot;, &quot;Item2&quot;, &quot;Item3&quot;, &quot;Item4&quot;]
myItems[5] := &quot;Item5&quot;
Loop, 5
MsgBox, % myItems[A_Index]</code></pre></div><p>Если нужно просто добавить в конец, без учёта порядкового номера:</p><div class="codebox"><pre><code>myItems := [&quot;Item1&quot;, &quot;Item2&quot;, &quot;Item3&quot;, &quot;Item4&quot;]
myItems.Push(&quot;Item5&quot;, &quot;Item6&quot;)
Loop, 6
MsgBox, % myItems[A_Index]</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-12-12T12:39:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109797#p109797</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109795#p109795" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, в справке не нашел примера, как добавить текст в заданное поле (массив).</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-12-12T10:58:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109795#p109795</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109793#p109793" />
			<content type="html"><![CDATA[<p>В файл скрипта можно дописывать командой <em>FileAppend</em>.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-12-12T10:39:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109793#p109793</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109792#p109792" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, как автоматически добавить пункт через запятую в данный массив? Нажимаю на кнопку - пункт добавляется в файле сценария.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-12-12T10:35:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109792#p109792</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109785#p109785" />
			<content type="html"><![CDATA[<p>Оператором присвоения.<br /></p><div class="codebox"><pre><code>myItems := [&quot;Item1&quot;, &quot;Item2&quot;, &quot;Item3&quot;, &quot;Item4&quot;]</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-12-12T09:43:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109785#p109785</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109784#p109784" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, а какой же коммандой добавить переменную в массив?</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-12-12T09:37:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109784#p109784</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109779#p109779" />
			<content type="html"><![CDATA[<p>Этот скрипт у меня на Windows XP не работает.</p><p>Насколько я понимаю, нужно изменить массив myItems, затем выполнить вот эту часть скрипта:<br /></p><div class="codebox"><pre><code>DllCall(&quot;RegisterShellHookWindow&quot;, UInt, A_ScriptHwnd)
CreateMyMenu := Func(&quot;CreateMyMenu&quot;).Bind(myMenuName, myItems)
ShellProc := Func(&quot;ShellProc&quot;).Bind(winClass, CreateMyMenu)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-12-12T06:16:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109779#p109779</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Добавление переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109777#p109777" />
			<content type="html"><![CDATA[<p>В соседней теме предлагался следующий сценарий, позволяющий разместить пользовательские пункты в панели меню стандартного окна:<br /></p><div class="codebox"><pre><code>#SingleInstance Force
winClass := &quot;Notepad&quot;
myMenuName := &quot;MyMenu&quot;
myItems := [&quot;Item1&quot;, &quot;Item2&quot;]

DllCall(&quot;RegisterShellHookWindow&quot;, UInt, A_ScriptHwnd)
CreateMyMenu := Func(&quot;CreateMyMenu&quot;).Bind(myMenuName, myItems)
ShellProc := Func(&quot;ShellProc&quot;).Bind(winClass, CreateMyMenu)
OnMessage(DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;SHELLHOOK&quot;), ShellProc)
OnExit(&quot;Exit&quot;)
Return

~LButton::
   if item := IsMouseOverMyMenu(winClass, myItems)
      MsgBox, % item
   Return
   
CreateMyMenu(menuName, items, hWnd)  {
   hMyMenu := DllCall(&quot;CreateMenu&quot;)
   for k, v in items
      DllCall(&quot;AppendMenu&quot;, Ptr, hMyMenu, UInt, MF_STRING := 0, UInt, &quot;&quot;, Str, v)
   
   hMenu := DllCall(&quot;GetMenu&quot;, Ptr, hWnd, Ptr)
   DllCall(&quot;AppendMenu&quot;, Ptr, hMenu, UInt, MF_POPUP := 0x10, Ptr, hMyMenu, Str, menuName)
   DllCall(&quot;DrawMenuBar&quot;, Ptr, hWnd)
}

ShellProc(myClass, myFunc, nCode, wParam)  {
   if ( nCode = (HSHELL_WINDOWCREATED := 1) )  {
      WinGetClass, winClass, ahk_id %wParam%
      if (winClass = myClass)
         myFunc.Call(wParam)
   }    
}
   
IsMouseOverMyMenu(myClass, items)  {
   WinGetClass, winClass, A
   if (winClass != myClass)
      Return
   
   MouseGetPos,,, ID
   WinGetClass, winClass, ahk_id %ID%
   if (winClass != &quot;#32768&quot;)
      Return
   
   AccObj := AccObjectFromPoint(child)
   item := AccObj.AccName(child)
   for k, v in items
      if (v == item)
         Return item
}

AccObjectFromPoint(ByRef _idChild_ = &quot;&quot;, x = &quot;&quot;, y = &quot;&quot;)  {
   static VT_DISPATCH := 9, h := DllCall(&quot;LoadLibrary&quot;, Str, &quot;oleacc&quot;, Ptr)
   
   (x = &quot;&quot; || y = &quot;&quot;) ? DllCall(&quot;GetCursorPos&quot;, Int64P, pt) : pt := x &amp; 0xFFFFFFFF | y &lt;&lt; 32
   VarSetCapacity(varChild, 8 + 2*A_PtrSize, 0)
   if   DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, Int64, pt, PtrP, pAcc, Ptr, &amp;varChild) = 0
      Return ComObjEnwrap(VT_DISPATCH, pAcc, 1), _idChild_ := NumGet(varChild, 8, &quot;UInt&quot;)
}

Exit()  {
    DllCall(&quot;DeregisterShellHookWindow&quot;, UInt, A_ScriptHwnd)
}
</code></pre></div><p>Отдельным действием хотелось бы добавлять пункты меню, т.е. добавлять переменные в myItems:<br /></p><div class="codebox"><pre><code>^+vk43:: ; с
ClipBoard := &quot;&quot;
Send, ^{vk43} ; с
InputBox, clipboardID, Save Preset, Preset Name:, , 180, 130
FileAppend, %ClipBoardAll%, %clipboardID%
; Добавить пункт меню (переменную) &quot;%clipboardID%&quot;
return
</code></pre></div><p>Какой командой это можно осуществить? Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-12-11T18:55:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109777#p109777</id>
		</entry>
</feed>
