<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15547&amp;type=atom" />
	<updated>2020-07-27T17:37:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15547</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141160#p141160" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>mkone112 пишет:</cite><blockquote><p>если зажать Enter и понажимать SC24-27 - будет периодически проскакивать enter</p></blockquote></div><p>У меня такого нет.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-07-27T17:37:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141160#p141160</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141156#p141156" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Происходит при быстром нажатии несколько раз. Это еще более заметно, если добавить другие клавиши в блок<br /></p><div class="codebox"><pre><code>#if EnterTime</code></pre></div><p>Пример:<br /></p><div class="codebox"><pre><code>
;если зажать Enter и понажимать SC24-27 - будет периодически проскакивать enter
#if EnterTime
SC21:: MyGuiFunction() 
SC24::Left
SC25::Up
SC26::Down
SC27::Right
Enter Up::
	if A_TickCount - EnterTime - (EnterTime := 0) &lt; 300 
		Send {Enter}
	Return 
#if !EnterTime
Enter:: EnterTime := A_TickCount 
#if 
</code></pre></div><p>Вот так вроде работает:<br /></p><div class="codebox"><pre><code>
#if GetKeyState(&quot;Enter&quot;, &quot;P&quot;)
    SC12:: MyGuiFunction()
#if


#if EnterTime
Enter Up::
  if (A_TickCount - EnterTime - (EnterTime := 0) &lt; 300 &amp;&amp; A_PriorKey == &quot;Enter&quot;)
    Send {Enter}
  return
#if


#if !EnterTime
Enter:: EnterTime := A_TickCount 
#if
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-27T16:28:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141156#p141156</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141155#p141155" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>mkone112 пишет:</cite><blockquote><p>А этот вариант периодически посылает Enter при нажатии Enter &amp; F</p></blockquote></div><p>У меня такого нет.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-07-27T15:58:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141155#p141155</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141152#p141152" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Я что-то поторопился, этот вариант тоже посылает Enter при отпускании после удержания более 0.3с<br /></p><div class="codebox"><pre><code>
#SingleInstance, force 

$Enter::
    ; остальной код
    KeyWait, Enter
    if (A_PriorKey == &quot;Enter&quot; &amp;&amp; A_TimeSinceThisHotkey &lt; 300)
            Send {Enter}
    ; остальной код
return
Enter &amp; SC12::MyGuiFunction() 

z::MyGuiFunction()

MyGuiFunction()  {

  Global MyEdit
  Gui, +LastFound
  GuiHWND := WinExist()           ;--get handle to this gui..

  Gui, Add , Text  ,        , Enter value
  Gui, Add , Edit  , vMyEdit,
  Gui, Add , Button, Default, OK
  Gui, Show
  WinWaitClose, ahk_id %GuiHWND%  ;--waiting for gui to close
  return ReturnCode               ;--returning value

  ButtonOK:
    GuiControlGet, ReturnCode, , MyEdit
    Gui, Destroy
  return

  GuiEscape:
  GuiClose:
    ReturnCode = -1
    Gui, Destroy
  return
}
</code></pre></div><p>А этот вариант периодически посылает Enter при нажатии Enter &amp; F<br /></p><div class="quotebox"><blockquote><p>Так ещё попробуйте.</p></blockquote></div><div class="codebox"><pre><code>
#if EnterTime
SC21:: MyGuiFunction() 

Enter Up::
	if A_TickCount - EnterTime - (EnterTime := 0) &lt; 300 
		Send {Enter}
	Return 
#if !EnterTime
Enter:: EnterTime := A_TickCount 
#if 
</code></pre></div><div class="codebox"><pre><code>#SingleInstance, force 

#if EnterTime
SC21:: MyGuiFunction() 

Enter Up::
  if A_TickCount - EnterTime - (EnterTime := 0) &lt; 300 
    Send {Enter}
  Return 
#if !EnterTime
Enter:: EnterTime := A_TickCount 
#if 

MyGuiFunction()  {

  Global MyEdit
  Gui, +LastFound
  GuiHWND := WinExist()           ;--get handle to this gui..

  Gui, Add , Text  ,        , Enter value
  Gui, Add , Edit  , vMyEdit,
  Gui, Add , Button, Default, OK
  Gui, Show
  WinWaitClose, ahk_id %GuiHWND%  ;--waiting for gui to close
  return ReturnCode               ;--returning value

  ButtonOK:
    GuiControlGet, ReturnCode, , MyEdit
    Gui, Destroy
  return

  GuiEscape:
  GuiClose:
    ReturnCode = -1
    Gui, Destroy
  return
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-27T15:18:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141152#p141152</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141123#p141123" />
			<content type="html"><![CDATA[<p>Так ещё попробуйте.<br /></p><div class="codebox"><pre><code>
#if EnterTime
SC21:: MyGuiFunction() 

Enter Up::
	if A_TickCount - EnterTime - (EnterTime := 0) &lt; 300 
		Send {Enter}
	Return 
#if !EnterTime
Enter:: EnterTime := A_TickCount 
#if 
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-07-26T15:07:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141123#p141123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141120#p141120" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Я немного доработал ваше решение и все вроде-бы работает. Большое спасибо!<br /></p><div class="codebox"><pre><code>
#SingleInstance, force 

$Enter::
    ; остальной код
    KeyWait, Enter
    if (A_PriorKey == &quot;Enter&quot; &amp;&amp; A_TimeSinceThisHotkey &lt; 300)
            Send {Enter}
    ; остальной код
return
Enter &amp; SC12::MyGuiFunction() 

z::MyGuiFunction()

MyGuiFunction()  {

  Global MyEdit
  Gui, +LastFound
  GuiHWND := WinExist()           ;--get handle to this gui..

  Gui, Add , Text  ,        , Enter value
  Gui, Add , Edit  , vMyEdit,
  Gui, Add , Button, Default, OK
  Gui, Show
  WinWaitClose, ahk_id %GuiHWND%  ;--waiting for gui to close
  return ReturnCode               ;--returning value

  ButtonOK:
    GuiControlGet, ReturnCode, , MyEdit
    Gui, Destroy
  return

  GuiEscape:
  GuiClose:
    ReturnCode = -1
    Gui, Destroy
  return
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-26T14:57:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141120#p141120</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141119#p141119" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Так вы объясните в чём для вас это функционально выражается, я тоже вижу что отличается.</p></blockquote></div><p>В первом варианте, при зажатии Enter более чем на 0.3сек - Enter не посылается.<br />Во втором - Enter посылается при сколь угодно долгом удержании.</p>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-26T14:29:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141119#p141119</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141118#p141118" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Можно без KeyWait, например:</p></blockquote></div><p>Если несколько раз нажать Enter &amp; f то посылается Enter.</p>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-26T14:26:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141118#p141118</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141117#p141117" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>mkone112 пишет:</cite><blockquote><p>Не эквивалентно этому:</p></blockquote></div><p>Так вы объясните в чём для вас это функционально выражается, я тоже вижу что отличается.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Интересный приём, не знал такого.</p></blockquote></div><p>Он периодически всплывает на форуме, но запоминается плохо из за своей неочивидности.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-07-26T14:02:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141117#p141117</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141116#p141116" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Так не проще?</p></blockquote></div><p>По идее это:<br /></p><div class="codebox"><pre><code>Enter:: Enter</code></pre></div><p>Не эквивалентно этому:<br /></p><div class="codebox"><pre><code>$SC1C::
    KeyWait, Enter
    if (A_PriorKey == &quot;Enter&quot; &amp;&amp; A_TimeSinceThisHotkey &lt; 300)
        Send {Enter}
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-26T13:34:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141116#p141116</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141115#p141115" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>f — это не SC12, это sc21.</p></blockquote></div><p>У меня Colemak</p>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-07-26T13:32:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141115#p141115</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141112#p141112" />
			<content type="html"><![CDATA[<p>Хотя в справке он <a href="https://www.autohotkey.com/docs/Hotkeys.htm#combo">упоминается</a>. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-07-26T11:54:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141112#p141112</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141111#p141111" />
			<content type="html"><![CDATA[<p>Интересный приём, не знал такого.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-07-26T11:37:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141111#p141111</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141110#p141110" />
			<content type="html"><![CDATA[<p>Так не проще?<br /></p><div class="codebox"><pre><code>
#SingleInstance, force 

Enter:: Enter
Enter &amp; SC21::MyGuiFunction() 

z::MyGuiFunction()

MyGuiFunction()  {

  Global MyEdit
  Gui, +LastFound
  GuiHWND := WinExist()           ;--get handle to this gui..

  Gui, Add , Text  ,        , Enter value
  Gui, Add , Edit  , vMyEdit,
  Gui, Add , Button, Default, OK
  Gui, Show
  WinWaitClose, ahk_id %GuiHWND%  ;--waiting for gui to close
  return ReturnCode               ;--returning value

  ButtonOK:
    GuiControlGet, ReturnCode, , MyEdit
    Gui, Destroy
  return

  GuiEscape:
  GuiClose:
    ReturnCode = -1
    Gui, Destroy
  return
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-07-26T11:24:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141110#p141110</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: При вызове Gui перестает работать переназначенная клавиша]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141109#p141109" />
			<content type="html"><![CDATA[<p>Можно без KeyWait, например:<br /></p><div class="codebox"><pre><code>
#SingleInstance, force
single_press_time := 300

info := {}, timer := Func(&quot;WaitEnter&quot;).Bind(info)
; Enter посылается только при одиночном зажатии менее чем на 300мс
$Enter::
    if !info.start {
        info.start := A_TickCount
        SetTimer, % timer, 10
    }
return

; Enter &amp; F вызывают Gui, и после этого Enter не работает
#if GetKeyState(&quot;Enter&quot;, &quot;P&quot;)
    SC21::MyGuiFunction()
#if

; Но при вызове Gui по нажатию z Enter работает
z::MyGuiFunction()

WaitEnter(info) {
    global single_press_time
    if !GetKeyState(&quot;Enter&quot;, &quot;P&quot;) {
        SetTimer,, Delete
        if (A_TickCount - info.start &lt; single_press_time)
            Send {Enter}
        info.start := &quot;&quot;
    }
}

MyGuiFunction()  {

  Global MyEdit
  Gui, +LastFound
  GuiHWND := WinExist()           ;--get handle to this gui..

  Gui, Add , Text  ,        , Enter value
  Gui, Add , Edit  , vMyEdit,
  Gui, Add , Button, Default, OK
  Gui, Show
  WinWaitClose, ahk_id %GuiHWND%  ;--waiting for gui to close
  return ReturnCode               ;--returning value

  ButtonOK:
    GuiControlGet, ReturnCode, , MyEdit
    Gui, Destroy
  return

  GuiEscape:
  GuiClose:
    ReturnCode = -1
    Gui, Destroy
  return
}</code></pre></div><p>f — это не SC12, это sc21.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-07-26T11:08:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141109#p141109</id>
		</entry>
</feed>
