<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12934&amp;type=atom" />
	<updated>2017-08-28T14:13:51Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12934</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118858#p118858" />
			<content type="html"><![CDATA[<p>Правда непонятно как тут использовать function object.<br /><a href="http://ahkscript.org/docs/commands/Gui.htm#Events">http://ahkscript.org/docs/commands/Gui.htm#Events</a><br /></p><div class="quotebox"><blockquote><p>[v1.1.20+]: If not a valid label name, a function name can be used instead. Alternatively, the GuiControl command can be used to associate a function object with the control.</p></blockquote></div><div class="codebox"><pre><code>MyTank := new Tank
MyTank.paint(10,10)
Return

class Tank  {
   paint(x,y)  {
	  obj := ObjBindMethod(This, &quot;get&quot;)
      Gui, Add, Button, Border x%x% y%y% g%obj% hwndPr1, Button
      this.Pr1 := Pr1
      Gui, Show
   }
	get() {
		MsgBox Вызов из тела объекта
	}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-28T14:13:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118858#p118858</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118856#p118856" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong> Спасибо огромное!</p>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-28T13:46:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118856#p118856</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118855#p118855" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>MyTank := new Tank
MyTank.paint(10,10)
Return

class Tank  {
   paint(x,y)  {
      Gui, Add, Button, Border x%x% y%y% gTank.TEST hwndPr1, Button
      this.Pr1 := Pr1
      Gui, Show
   }
	TEST() {
		MsgBox Вызов из тела объекта
	}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-28T13:42:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118855#p118855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118854#p118854" />
			<content type="html"><![CDATA[<p>Форумчане, подскажите пожалуйста как из объекта, по нажатию кнопки создающейся в классе, вызвать метод?<br /></p><div class="codebox"><pre><code>MyTank := new Tank
MyTank.paint(10,10)

class Tank  {
   paint(x,y)  {
      Gui, Add, Button, Border x%x1% y%y1% gTEST hwndPr1, Button
      this.Pr1 := Pr1
      Gui, Show
   }
TEST() {
MsgBox Вызов из тела объекта
}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-28T13:35:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118854#p118854</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118722#p118722" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong> Пардон, конечно же объекты из классов.</p>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-24T13:42:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118722#p118722</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118719#p118719" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Raven пишет:</cite><blockquote><p>можно будет создавать классы не из IDE в autohotkey&#039;е, а прям из окна</p></blockquote></div><p>Вы имеете ввиду именно классы, или всё же их экземпляры?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-24T10:03:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118719#p118719</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118717#p118717" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong> Да так же записать конфигурацию в файл и потом ее загружать при старте программы.</p>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-24T05:51:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118717#p118717</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118687#p118687" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Raven пишет:</cite><blockquote><p>что бы объект знал свое имя</p></blockquote></div><p>Тогда проще так:<br /></p><div class="codebox"><pre><code>MyTank.name := &quot;MyTank&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-23T14:25:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118687#p118687</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118685#p118685" />
			<content type="html"><![CDATA[<p>С классами не работал, но предполагаю (справку лень читать), что можно любые параметры в класс передавать.<br /></p><div class="codebox"><pre><code>MyTank := new Tank
MyTank.paint(10,10)
Loop  {
   Sleep, 10
   GuiControl,, % MyTank.Pr1, % A_Index
}

class Tank  {
   paint(x,y)  {
      x1 := x + 80
      y1 := y + 10
      Gui, Add, Progress, Border w10 h150 x%x1% y%y1% vertical cBlue hwndPr1
      this.Pr1 := Pr1
      Gui, Show
   }
}</code></pre></div><div class="quotebox"><cite>Raven пишет:</cite><blockquote><p>можно будет создавать классы не из IDE в autohotkey&#039;е, а прям из окна gui по нажатию кнопки?</p></blockquote></div><p>А как потом все эти элементы сохранять загружать?</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2017-08-23T14:13:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118685#p118685</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118683#p118683" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Это мне нужно для того что бы объект знал свое имя и мог его сразу же отрисовать в gui.<br /><strong>serzh82saratov</strong> Спасибо большое за ответ. Раз по другому нельзя, будем делать так как вы посоветовали.</p>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-23T13:45:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118683#p118683</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118681#p118681" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Raven пишет:</cite><blockquote><p>А как можно получить имя объекта внутри класса?</p></blockquote></div><p>А зачем это может понадобиться? Классу ничего не известно про его экземпляры, их может быть множество, разве что передать вручную, как выше.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-23T13:33:45Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118681#p118681</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118677#p118677" />
			<content type="html"><![CDATA[<p>Наверное только так.<br /></p><div class="codebox"><pre><code>MyTank := new Tank(&quot;MyTank&quot;)
MyTank.paint()

class Tank  {
   x := 10, y := 10
   __new(name)  {
     this.name := name
   }
   paint()  {
      MsgBox % this.name
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-23T12:31:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118677#p118677</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118672#p118672" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> То что нужно! Именно этого мне и не хватало! Спасибо! А как можно получить имя объекта внутри класса? То есть в вашем примере это будет MyTank. С помощью this.__Class мы получаем тип объекта, то есть Tank.</p>]]></content>
			<author>
				<name><![CDATA[Raven]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30150</uri>
			</author>
			<updated>2017-08-23T10:44:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118672#p118672</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118648#p118648" />
			<content type="html"><![CDATA[<p><strong>Raven</strong>, если создаёте GUI внутри класса, лучше для идентификаторов контролов использовать их hwnd, тогда не придётся их объявлять глобальными или статическими:<br /></p><div class="codebox"><pre><code>MyTank := new Tank
MyTank.paint()
Loop  {
   Sleep, 10
   GuiControl,, % MyTank.Pr1, % A_Index
}

class Tank  {
   x := 10, y := 10
   paint()  {
      x1 := this.x + 80
      y1 := this.y + 10
      Gui, Add, Progress, Border w10 h150 x%x1% y%y1% vertical cBlue hwndPr1
      this.Pr1 := Pr1
      Gui, Show
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-22T12:26:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118648#p118648</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Использование переменных внутри классов]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118646#p118646" />
			<content type="html"><![CDATA[<p>Ну так оно же вам само говорит &quot;Контрольная переменная должна быть глобальной или статической&quot;, а чтобы понять что вам нужно, надо привести пример как (откуда) вы хотите менять текст.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-22T09:15:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118646#p118646</id>
		</entry>
</feed>
