<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18093</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18093&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как застваить gLabel vCheckbox работать в заданном окне?».]]></description>
		<lastBuildDate>Tue, 06 Feb 2024 16:48:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160261#p160261</link>
			<description><![CDATA[<p>Пожалуйста, только точку верните на место.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 06 Feb 2024 16:48:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160261#p160261</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160260#p160260</link>
			<description><![CDATA[<p>Понял, спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Tue, 06 Feb 2024 16:10:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160260#p160260</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160259#p160259</link>
			<description><![CDATA[<div class="quotebox"><cite>uNseen пишет:</cite><blockquote><div class="codebox"><pre><code>OptionAscript:
{
	SendInput, {x}
	While GetKeyState(&quot;x&quot;,&quot;P&quot;)
	Send, {RButton}
	Return
}
return ;&lt;---------- Здесь необходим return?</code></pre></div></blockquote></div><p>Фигурные скобки вокруг содержимого метки не нужны. Должно выглядеть так:<br /></p><div class="codebox"><pre><code>OptionAscript:
	SendInput, {x}
	While GetKeyState(&quot;x&quot;,&quot;P&quot;)
	Send, {RButton}
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 06 Feb 2024 15:59:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160259#p160259</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160256#p160256</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Еще такой вопрос. </p><p>Допустим есть скрипт, в конце которого return</p><div class="codebox"><pre><code>$x::
	SendInput, {x}
	While GetKeyState(&quot;x&quot;,&quot;P&quot;)
	Send, {RButton}
Return</code></pre></div><br /><p>При имплементации этого скрипта через Label нужен ли еще один return?<br /></p><div class="codebox"><pre><code>
Label:
GuiControlGet, Checkbox1
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return


OptionAscript:
{
	SendInput, {x}
	While GetKeyState(&quot;x&quot;,&quot;P&quot;)
	Send, {RButton}
	Return
}
return ;&lt;---------- Здесь необходим return?
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Tue, 06 Feb 2024 15:03:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160256#p160256</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160254#p160254</link>
			<description><![CDATA[<p>Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Tue, 06 Feb 2024 14:04:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160254#p160254</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160249#p160249</link>
			<description><![CDATA[<p>Команда <em>Hotkey, If, WinActive(main)</em> действует на все горячие клавиши, созданные через Hotkey, расположенные ниже. Чтобы отключить это условие, вызовите перед объявлением горячей клавиши <em>Hotkey, If</em>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 06 Feb 2024 05:39:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160249#p160249</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160245#p160245</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Скорее всего, плохо знакомы, #If используется только для горячих клавиш.</p></blockquote></div><p>Так я и не говорил, что хорошо знаком... ) О таких нюансах мне, конечно, не известно</p><br /><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Но я тоже не очень внимательно прочитал вопрос.</p><div class="quotebox"><cite>uNseen пишет:</cite><blockquote><p>как грамотно заставить работать приведенный в данном примере $x hotkey только в окне main</p></blockquote></div><p>Для горячих клавиш, созданных с помощью команды Hotkey, используется <a href="https://www.autohotkey.com/docs/v1/lib/Hotkey.htm">Hotkey, If [, Expression]</a>.</p></blockquote></div><p>Спасибо за наводку, у меня получилось, добавив <span style="color: red">Hotkey, IfWinActive , %main%</span></p><div class="codebox"><pre><code>Label:
GuiControlGet, Checkbox1
Hotkey, IfWinActive , %main%
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return

Label2:
GuiControlGet, Checkbox2
Hotkey, $x, OptionBscript, % Checkbox2 ? &quot;On&quot; : &quot;Off&quot;
Return
</code></pre></div><p>Я уже очень рад!!! потому что долгое время мучился с этим вопросом.</p><p>Но есть нюанс. <span style="color: red">Hotkey, IfWinActive , %main%</span> при этом распространяется и на Label2, хотя я там эту строку кода не прописывал. Если я запущу GUI и ни разу не использую Checkbox1, то Label2 будет работать в любых окнах, как и положено, поскольку там конкретное окно не прописано. Но если я в процессе эксплуатации GUI активирую checkbox1 хотя бы один раз (и дезактивирую), Label2 станет работать только в том окне, которое прописано в Label1 (в данном случае main).<br />Это как-то можно исправить?</p><p>Также я попробовал ваш пример, ситуация повторяется:</p><div class="codebox"><pre><code>Label:
Hotkey, If, WinActive(main)
GuiControlGet, Checkbox1
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return

#If WinActive(main)
#If


Label2:
GuiControlGet, Checkbox2
Hotkey, $x, OptionBscript, % Checkbox2 ? &quot;On&quot; : &quot;Off&quot;
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Tue, 06 Feb 2024 01:26:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160245#p160245</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160244#p160244</link>
			<description><![CDATA[<p>На всякий случай пример:<br /></p><div class="codebox"><pre><code>Hotkey, If, WinActive(&quot;ahk_class Notepad&quot;)
Hotkey, x, Label, On
return

Label:
   MsgBox Это сообщение появится`, только когда активно окно блокнота.
return

#If WinActive(&quot;ahk_class Notepad&quot;)
#If</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 05 Feb 2024 23:29:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160244#p160244</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160242#p160242</link>
			<description><![CDATA[<div class="quotebox"><cite>uNseen пишет:</cite><blockquote><p>Я знаком с #If</p></blockquote></div><p>Скорее всего, плохо знакомы, #If используется только для горячих клавиш.<br />Но я тоже не очень внимательно прочитал вопрос.<br /></p><div class="quotebox"><cite>uNseen пишет:</cite><blockquote><p>как грамотно заставить работать приведенный в данном примере $x hotkey только в окне main</p></blockquote></div><p>Для горячих клавиш, созданных с помощью команды Hotkey, используется <a href="https://www.autohotkey.com/docs/v1/lib/Hotkey.htm">Hotkey, If [, Expression]</a>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 05 Feb 2024 23:15:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160242#p160242</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160240#p160240</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Читайте про <a href="https://www.autohotkey.com/docs/v1/lib/_If.htm">#If</a>.</p></blockquote></div><p>Я знаком с #If. Если я добавлю #If WinActive(main), на первый взгляд все работает как надо:</p><div class="codebox"><pre><code>#If WinActive(main)  ;&lt;&lt;&lt;----------- добавляю #If WinActive(main)
Label:
GuiControlGet, Checkbox1
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return


Label2:
GuiControlGet, Checkbox2
Hotkey, $x, OptionBscript, % Checkbox2 ? &quot;On&quot; : &quot;Off&quot;
Return
#If					;&lt;&lt;&lt;---------- Закрываю #If

OptionAscript:
{
    SendInput, {x}
    While GetKeyState(&quot;x&quot;,&quot;P&quot;)
    Send, {RButton}
    Return
}


OptionBscript:
{
    SendInput, {x}{Rbutton down}
    keywait, x
    SendInput, {Rbutton up}
    return
}</code></pre></div><p>Но если добавить ниже код на активацию третьего чекбокса, который должен работать в другом окне, тогда Label1 и Label2 перестают работать в основном окне (main).<br /></p><div class="codebox"><pre><code>
#If WinActive(main)  ;&lt;&lt;&lt;----------- добавляю #If WinActive(main)
Label:
GuiControlGet, Checkbox1
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return


Label2:
GuiControlGet, Checkbox2
Hotkey, $x, OptionBscript, % Checkbox2 ? &quot;On&quot; : &quot;Off&quot;
Return
#If					;&lt;&lt;&lt;---------- Закрываю #If

OptionAscript:
{
    SendInput, {x}
    While GetKeyState(&quot;x&quot;,&quot;P&quot;)
    Send, {RButton}
    Return
}


OptionBscript:
{
    SendInput, {x}{Rbutton down}
    keywait, x
    SendInput, {Rbutton up}
    return
}


#If Checkbox3 &amp;&amp; WinActive(win1)
$r::
Send, v
Return
#If
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Mon, 05 Feb 2024 20:47:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160240#p160240</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160239#p160239</link>
			<description><![CDATA[<p>Читайте про <a href="https://www.autohotkey.com/docs/v1/lib/_If.htm">#If</a>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 05 Feb 2024 20:12:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160239#p160239</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как застваить gLabel vCheckbox работать в заданном окне?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160235#p160235</link>
			<description><![CDATA[<p>Всем дробового времени суток!</p><p>Помогите пожалуйста, как грамотно заставить работать приведенный в данном примере $x hotkey только в окне main (main := &quot;main window&quot;)?</p><div class="codebox"><pre><code>global win1 := &quot;window1&quot;
global main := &quot;main window&quot;

Gui, -border
Gui, Add, Checkbox, gLabel vCheckbox1, Option A
Gui, Add, Checkbox, gLabel2 vCheckbox2, Option B
Gui, Add, Checkbox, vCheckbox3, Option C

Gui, Add, Button, w80 Default, OK
Gui, Add, Button, w80, Cancel
return

OnMessage(0x4A, &quot;WM_NOTIFY&quot;)
Return

WM_NOTIFY(wParam, lParam) {
    Gui, Submit, NoHide
    If (lParam = 0x114)
    {

    }
    Return
}

ButtonOK:
    Gui, Submit
    Gui, Cancel
Return

ButtonCancel:
    Gui, Cancel
Return

;---------------- GUI hotkeys ----------------
^!g::
  Gui, Show, , Creator
return

Label:
GuiControlGet, Checkbox1
Hotkey, $x, OptionAscript, % Checkbox1 ? &quot;On&quot; : &quot;Off&quot;
Return


Label2:
GuiControlGet, Checkbox2
Hotkey, $x, OptionBscript, % Checkbox2 ? &quot;On&quot; : &quot;Off&quot;
Return


OptionAscript:
{
    SendInput, {x}
    While GetKeyState(&quot;x&quot;,&quot;P&quot;)
    Send, {RButton}
    Return
}


OptionBscript:
{
    SendInput, {x}{Rbutton down}
    keywait, x
    SendInput, {Rbutton up}
    return
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (uNseen)]]></author>
			<pubDate>Mon, 05 Feb 2024 15:31:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160235#p160235</guid>
		</item>
	</channel>
</rss>
