<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: #include подружить с переменными]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11497&amp;type=atom" />
	<updated>2023-03-06T13:05:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11497</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157032#p157032" />
			<content type="html"><![CDATA[<p>Спасибо за совет, но наконец разобрался как все правильно делать.<br />Немного поэкспериментировав так и сяк, выяснил что в инклудах тоже надо делать свой return либо сразу либо после определения глобальных переменных и констант - после этого все начинает работать нормально и никаких ошибок не вылезает.<br />То есть каждый инклуд должен быть вида :<br /></p><div class="codebox"><pre><code>return

#ifwinactive Paint
f1::
  msgbox f1
return
#ifwinactive</code></pre></div><p>Так-то да, глобальные переменные вещь довольно своеобразная и ее лучше использовать с умом.<br />Функции конечно логичнее, но когда используется сложная логика с переходами по goto, то они немного не в кассу.</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2023-03-06T13:05:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157032#p157032</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157016#p157016" />
			<content type="html"><![CDATA[<p>Если проблема в том, что определения горячих клавиш мешают перед секцией автовыполнения, сделайте в начале include goto на нужное место.<br />Но вообще по-хорошему нужно использовать функции, а не метки, а глобальных переменных либо не должно быть совсем, либо предельно мало.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-03-04T10:37:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157016#p157016</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157015#p157015" />
			<content type="html"><![CDATA[<p>Скрипт сейчас у меня один и в него, чтобы не запускать множество отдельных ahk, напихано множество разнородного содержимого.</p><p>Хотелось бы из скрипта вынести участки такого кода в отдельные файлы, где они будут сложены по типам - отдельно системные, отдельно для программ рисования, отдельно для музыки видео, отдельно для игр, например, общие участки для эмуляторов и игровых центров.</p><p>Так-то, определение всех функций, которые мог, уже вынес в отдельные скрипты и подключаю через инклуды, а вот эти определения хоткеев остались в одной куче - и, думаю, пришла пора их как-то упорядочить и структурировать, чтобы не пытаться искать среди кода для фотошопа код для mpc или winamp&#039;а.</p><p>Еще проблема в том, что ни akelpad ни notepad++ не понимают директивы ahk (#if, #ifwinactive и прочие) и следовательно сворачивать/разворачивать их не умеют, чтобы упростить редактирование и навигацию в скриптах когда их много. Так что проще открыть несколько вкладок с тематическими скриптами, чем пытаться ориентироваться в одном файле.</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2023-03-04T08:50:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157015#p157015</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157004#p157004" />
			<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>2023-03-03T20:56:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157004#p157004</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157003#p157003" />
			<content type="html"><![CDATA[<p>У меня аналогичный вопрос - возможно ли перенести определения такого вида в отдельный файл и сделать ему #include в начале основного скрипта чтобы получилось нечто вроде<br /><strong>start.ahk</strong><br /></p><div class="codebox"><pre><code>#include soft.ahk

f1::lbutton</code></pre></div><p><strong>soft.ahk</strong><br /></p><div class="codebox"><pre><code>#ifwinactive Paint
f1::
  msgbox f1
return
#ifwinactive</code></pre></div><p>У меня спотыкается на return, а переопределять через hotkey мне чет не хочется - хочется сохранить нативность кода.</p><p>Оборачивать все такое в функции такого вида?<br /></p><div class="codebox"><pre><code>f1::paint_f1()

paint_f1()
{
  msgbox f1
}</code></pre></div><p>Так неудобно получается и есть проблемы с глобальными переменными, которые заманаешься перечислять через global.</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2023-03-03T20:42:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157003#p157003</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103733#p103733" />
			<content type="html"><![CDATA[<p><strong>YMP</strong>, Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-05-13T11:00:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103733#p103733</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103714#p103714" />
			<content type="html"><![CDATA[<p><strong>becauseim</strong><br />Выполнение останавливается, если встречает команды Return и Exit, я ведь уже об этом упоминал.<br /></p><div class="codebox"><pre><code>
}
return

#Include 1.ahk ; частично работает, но не работает GUI из этого вложенного сркипта
#Include 2.ahk ; работает
</code></pre></div><p>Этот Return у вас не нужен, т.к. конец определения функции обозначен закрывающей фигурной скобкой.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2016-05-13T03:05:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103714#p103714</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103709#p103709" />
			<content type="html"><![CDATA[<p>Лично мне не хватает мотивации искать камень преткновения в чужих сложных скриптах. Особенно, когда вопрошающий затрудняется сформулировать вопрос.<br />Могу научить простому методу (метод исключения). Добавляешь в скрипт новые команды постепенно. Если скрипт начнёт работать неправильно, значит проблема в последней добавленной команде.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-05-12T20:41:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103709#p103709</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103708#p103708" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, я признателен Вашему желанию сподвигнуть пользователей на изучение языка, но для меня программирование как явление достаточно сложное для понимания. По крайней мере, сейчас.</p><p>С надежой на подсказку, повторюсь:<br />Что необходимо сделать, чтобы приведенный скрипт не воздействовал на вложенный за ним <a href="http://forum.script-coding.com/viewtopic.php?pid=103429#p103429">сценарий с элементами GUI</a>? </p><div class="codebox"><pre><code>OnMessage(0x404, &quot;AHK_NOTIFYICON&quot;)
AHK_NOTIFYICON(wParam, lParam)
{
    if (lParam = 0x202) ; WM_LBUTTONUP
    {
        Suspend
        return 1
    }
    else if (lParam = 0x205) ; WM_RBUTTONUP
    {
        Menu, Tray, Show
        Sleep 1000
        return 1 ; In case of load failure.
    }
    else if (lParam = 0x208) ; WM_MBUTTONUP
    {
        Reload
        return 1
    }
}
return

#Include 1.ahk ; частично работает, но не работает GUI из этого вложенного сркипта
#Include 2.ahk ; работает</code></pre></div>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-05-12T20:21:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103708#p103708</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103705#p103705" />
			<content type="html"><![CDATA[<p>Чтобы повысить грамотность, изучите команды, использованные в Ваших скриптах.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-05-12T17:04:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103705#p103705</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103704#p103704" />
			<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-05-12T16:58:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103704#p103704</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103702#p103702" />
			<content type="html"><![CDATA[<p><a href="http://www.script-coding.com/AutoHotkey/Scripts.html#chapter_1">http://www.script-coding.com/AutoHotkey … #chapter_1</a></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-05-12T16:48:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103702#p103702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103701#p103701" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, спасибо, работает!<br /><strong>ypppu</strong>, попробовал поискать одноименную статью, к сожалению, не нашел.</p><p>Например, если в сценарий перед двумя вложенными скриптами разместить ниже приведенный код, то работает все, кроме GUI одного из вложенных скриптов. А если разместить приведенный код после вложенных, то работают только вложенные скрипты, включая GUI.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Как это выглядит:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>OnMessage(0x404, &quot;AHK_NOTIFYICON&quot;)
AHK_NOTIFYICON(wParam, lParam)
{
    if (lParam = 0x202) ; WM_LBUTTONUP
    {
        Suspend
        return 1
    }
    else if (lParam = 0x205) ; WM_RBUTTONUP
    {
        Menu, Tray, Show
        Sleep 1000
        return 1 ; In case of load failure.
    }
    else if (lParam = 0x208) ; WM_MBUTTONUP
    {
        Reload
        return 1
    }
}
return

#Include 1.ahk ; не работает GUI из этого вложенного сркипта
#Include 2.ahk</code></pre></div><div class="codebox"><pre><code>
#Include 1.ahk 
#Include 2.ahk

; далее не работает

OnMessage(0x404, &quot;AHK_NOTIFYICON&quot;)
AHK_NOTIFYICON(wParam, lParam)
{
    if (lParam = 0x202) ; WM_LBUTTONUP
    {
        Suspend
        return 1
    }
    else if (lParam = 0x205) ; WM_RBUTTONUP
    {
        Menu, Tray, Show
        Sleep 1000
        return 1 ; In case of load failure.
    }
    else if (lParam = 0x208) ; WM_MBUTTONUP
    {
        Reload
        return 1
    }
}
return
</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-05-12T16:36:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103701#p103701</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103699#p103699" />
			<content type="html"><![CDATA[<p>Для понимания советую прочитать в русской справке про секцию авто-выполнения.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-05-12T16:07:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103699#p103699</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: #include подружить с переменными]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103698#p103698" />
			<content type="html"><![CDATA[<p>Потому что идет вечный цикл.<br />Так будет работать:<br /></p><div class="codebox"><pre><code>#IfWinActive, Total Commander
Shift::
if (Count = &quot;&quot;)
   Count := 0
arr:=[&quot;^{f3}^{vk52}&quot;, &quot;^{f5}^{vk52}&quot;, &quot;^{f6}^{vk52}&quot;, &quot;^{f4}^{vk52}&quot;]
SendInput % arr[Count := Count*((A_PriorHotkey = A_ThisHotkey)&amp;&amp;(A_TimeSincePriorHotkey&lt;250))+1]
return</code></pre></div><p>Либо так:<br /></p><div class="codebox"><pre><code>#IfWinActive, Total Commander
Shift::
Count += 0
arr:=[&quot;^{f3}^{vk52}&quot;, &quot;^{f5}^{vk52}&quot;, &quot;^{f6}^{vk52}&quot;, &quot;^{f4}^{vk52}&quot;]
SendInput % arr[Count := Count*((A_PriorHotkey = A_ThisHotkey)&amp;&amp;(A_TimeSincePriorHotkey&lt;250))+1]
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-05-12T15:55:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103698#p103698</id>
		</entry>
</feed>
