<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Разное поведение LControl на разных машинах]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13698&amp;type=atom" />
	<updated>2018-05-10T20:31:46Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13698</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Разное поведение LControl на разных машинах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125294#p125294" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>#MaxHotkeysPerInterval 1000 ; avoid reaction on ~LControl system autorepeat
#If Not (GetKeyState(&quot;LButton&quot;) || GetKeyState(&quot;RButton&quot;) || GetKeyState(&quot;MButton&quot;))
~LControl:: keyPressed ? : (downTime := A_TickCount, keyPressed := true)
#If keyPressed And Not (GetKeyState(&quot;LButton&quot;) || GetKeyState(&quot;RButton&quot;) || GetKeyState(&quot;MButton&quot;))
~LControl Up:: !(keyPressed := false) &amp;&amp; A_PriorHotKey = &quot;~LControl&quot; &amp;&amp; A_TickCount-downTime &lt; 1000 &amp;&amp; SwitchLocale()
#If
*~LButton::
*~RButton::
*~MButton::
Return

SwitchLocale()  {
	PostMessage 0x50, 0x2,,, % &quot;ahk_id&quot; ((hWndOwn:=DllCall(&quot;GetWindow&quot;, Ptr, hWnd:=WinExist(&quot;A&quot;), UInt, 4, Ptr)) ? hWndOwn : hWnd)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2018-05-10T20:31:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125294#p125294</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Разное поведение LControl на разных машинах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125292#p125292" />
			<content type="html"><![CDATA[<p>Спасибо.</p><p>Похоже, что оба этих варианта не учитывают, что:<br />а) системный повтор Ctrl прерывается при нажатии любой клавиши, но не прерывается при нажатии кнопки мышки;<br />б) при нажатии любой клавиши одновременно с Ctrl (в т.ч. и кнопок мышки), переключение языка не должно происходить.</p><p>Вот мой вариант. Он безусловно более примитивный, но учитывает эти 2 момента:</p><div class="codebox"><pre><code>
~LControl::
if (!PriorKey)
    PriorKey := &quot;LControl&quot;
else if (A_PriorKey &lt;&gt; &quot;LControl&quot;)
    PriorKey := A_PriorKey
return
~LControl Up::
if (A_PriorKey = &quot;LControl&quot; and PriorKey = &quot;LControl&quot;)
{
    Send {Control Down}{Shift}{Control Up}
	SoundBeep, 5000, 100
}
PriorKey =
return
</code></pre></div><p>Родился в результате ~3ч чтения мануала по AHK. Буду благодарен за критику.</p>]]></content>
			<author>
				<name><![CDATA[zmey78]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39058</uri>
			</author>
			<updated>2018-05-10T19:30:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125292#p125292</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Разное поведение LControl на разных машинах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125289#p125289" />
			<content type="html"><![CDATA[<p>TimeSincePriorHotkey != TimeSincePriorKey, встроенной переменной для TimeSincePriorKey не предусмотрено. Выконечно можете создать пустой хоткей на нажатие и тогда использовать A_TimeSincePriorHotkey , но системный автоповтор нажатия убъет эту затею.<br /></p><div class="codebox"><pre><code>#MaxHotkeysPerInterval 1000 ; avoid reaction on ~LControl system autorepeat
~LControl:: keyPressed ? : (downTime := A_TickCount, keyPressed := true)
~LControl Up:: !(keyPressed := false) &amp;&amp; A_PriorKey = &quot;LControl&quot; &amp;&amp; (A_TickCount - downTime &lt; 500) &amp;&amp; SwitchLocale()

SwitchLocale()  {
	; ControlGetFocus CtrlFocus, A
	; PostMessage WM_INPUTLANGCHANGEREQUEST := 0x50, INPUTLANGCHANGE_FORWARD := 0x2,, % CtrlFocus, A
	PostMessage WM_INPUTLANGCHANGEREQUEST:=0x50, INPUTLANGCHANGE_FORWARD:=0x2,,, % &quot;ahk_id&quot; ((hWndOwn:=DllCall(&quot;GetWindow&quot;, Ptr, hWnd:=WinExist(&quot;A&quot;), UInt, GW_OWNER:=4, Ptr)) ? hWndOwn : hWnd)
}</code></pre></div><p>Если нужно чтобы работало на панели задач или конкретные языки, загляните сюды:<br /><a href="http://forum.script-coding.com/viewtopic.php?id=12452">http://forum.script-coding.com/viewtopic.php?id=12452</a></p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2018-05-10T18:52:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125289#p125289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Разное поведение LControl на разных машинах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125283#p125283" />
			<content type="html"><![CDATA[<p>Попробуйте так:<br /></p><div class="codebox"><pre><code>~LControl Up:: ( A_PriorKey = &quot;LControl&quot; &amp;&amp; ChangeLocale() )

ChangeLocale()  {
   ControlGetFocus, CtrlFocus, A
   PostMessage, WM_INPUTLANGCHANGEREQUEST := 0x50, INPUTLANGCHANGE_FORWARD := 0x2,, %CtrlFocus%, A
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-05-10T16:00:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125283#p125283</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Разное поведение LControl на разных машинах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125272#p125272" />
			<content type="html"><![CDATA[<p>У меня прекрасно работает этот скрипт на ноутбуке:<br /></p><div class="codebox"><pre><code>
~LControl Up::
if (A_PriorKey = &quot;LControl&quot; and (A_TimeSincePriorHotkey &gt; 400 or A_PriorHotkey &lt;&gt; A_ThisHotkey))
{
    Send {Control Down}{Shift}{Control Up}
	SoundBeep, 5000, 100
}
return
</code></pre></div><p>Смысл такой, что переключаем язык по Ctrl (как было в DOS), но только если не была нажата еще какая то клавиша, т.е. фильтруем обычные хоткеи.</p><p>Попробовал на стационарном компе, нажатие и удержание Ctrl превращается в бесконечный повтор Ctrl Down:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>A2&nbsp; 01D	 	d	2.48	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />01&nbsp; 000	 	d	0.06	LButton&nbsp; &nbsp; &nbsp; &nbsp; 	<br />A2&nbsp; 01D	 	d	0.19	LControl&nbsp; &nbsp; &nbsp; &nbsp;	*new 1 - Notepad++<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.05	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />01&nbsp; 000	 	u	0.02	LButton&nbsp; &nbsp; &nbsp; &nbsp; 	<br />A2&nbsp; 01D	 	d	0.02	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.05	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	 	d	0.03	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />A2&nbsp; 01D	h	u	0.01	LControl&nbsp; &nbsp; &nbsp; &nbsp;	<br />11&nbsp; 01D	i	d	0.00	Control&nbsp; &nbsp; &nbsp; &nbsp; 	<br />10&nbsp; 02A	i	d	0.00	Shift&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 	<br />10&nbsp; 02A	i	u	0.00	Shift&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 	<br />11&nbsp; 01D	i	u	0.00	Control</p></div></div><p>Плохо тем, что мой скрипт не видит, например, что я между нажатием и отжатием Ctrl нажимаю кнопку мыши для перетаскивания текста. Соответственно, язык переключается когда не нужно.</p><p>Пока придумал вариант, но еще не написал код для него, возможно не будет работать. Хочу послушать советы, как лучше и правильно сделать. А потом приведу свой вариант, чтобы сравнить. Подскажите, пожалуйста!!!</p>]]></content>
			<author>
				<name><![CDATA[zmey78]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39058</uri>
			</author>
			<updated>2018-05-10T09:52:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125272#p125272</id>
		</entry>
</feed>
