<?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=6767&amp;type=atom" />
	<updated>2012-02-19T13:26:45Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=6767</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=57071#p57071" />
			<content type="html"><![CDATA[<p>Да, точно!<br />Закомментировал эту строчку - заработало!<br />Притом, как вы сами сказали - она необязательна.<br />Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-19T13:26:45Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=57071#p57071</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=57069#p57069" />
			<content type="html"><![CDATA[<p>Не понятно, что конкретно значит &quot;не могут ужиться&quot;, но подозреваю это из-за вызова &quot;WinWaitNotActive&quot;- эта функция ждёт деактивации окна и не возвращает управление пока это событие не произойдёт, т.е. раскладки будут проверятся только при смене активных окон.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-02-19T13:18:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=57069#p57069</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=57063#p57063" />
			<content type="html"><![CDATA[<p>Александр_, случилась незадача - эти 2 кода не могут ужиться.<br /></p><div class="codebox"><pre><code>r := Array()
Color = 0x00000C 
Color1 = 0x0C0000
Color2 = 0x000C00
x = 500
y = 500
w = 1 
h = 1
loop
{   
  ;   1ый код
    If (InputLayout() = &quot;Russian&quot;)
    {   
	Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
	Gui, Color, % Color
	Gui, Show, x%x% y%y% w%w% h%h% NA
    }
    Else If (InputLayout() = &quot;Latvian&quot;)
    {   
	Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
	Gui, Color, % Color1
	Gui, Show, x%x% y%y% w%w% h%h% NA
    }
    Else If (InputLayout() = &quot;English&quot;)
    {   
	Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
	Gui, Color, % Color2
	Gui, Show, x%x% y%y% w%w% h%h% NA
    }

  ;   2ой код

   id := 0|WinExist(&quot;A&quot;) ;берём активное окно!
   WinGetTitle, Title, ahk_id%id% ;получаем его заголовок
   if(InStr(Title, &quot;OOo-dev&quot;)&amp;&amp;(!r[&quot;_&quot; . id])) ;Если в заголовке есть слово &quot;Блокнот&quot; и окна нет в списке
   {
     Winrestore, ahk_id%id%
      winmove, ahk_id%id%,, 0,0,%a_screenwidth%, %A_ScreenHeight% 
      r[&quot;_&quot; . id] := id
   }
   WinWaitNotActive, ahk_id%id%
   For Key, value in r
   {
      IfWinNotExist, ahk_id%value%
      {
         r.Remove(Key)
      }
   }
   sleep, 50
}
 
InputLayout()
{
    ThreadID := DllCall(&quot;GetWindowThreadProcessId&quot;, &quot;Int&quot;, WinExist(&quot;A&quot;), &quot;Int&quot;, 0)
    HKL := DllCall(&quot;GetKeyboardLayout&quot;, &quot;uint&quot;, ThreadID, &quot;UShort&quot;)
    VarSetCapacity(sKbd, 260, 0)
    DllCall(&quot;GetLocaleInfo&quot;, &quot;uint&quot;, HKL
                           , &quot;uint&quot;, 0x1001
                           , &quot;str&quot;,  sKbd
                           , &quot;uint&quot;, 260)
    Return sKbd
}</code></pre></div><p>И я подозреваю это из-за конфликта </p><div class="quotebox"><blockquote><p>WinExist(&quot;A&quot;)</p></blockquote></div><p>Можно ли во втором коде, это чем-нибудь заменить?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-19T12:18:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=57063#p57063</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56558#p56558" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Ничего себе сколько тонкостей и сложностей, казалось бы для простой задачи.</p></blockquote></div><p>Тут скорее баг, чем тонкость <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><div class="codebox"><pre><code>  For Key, value in r
   {
      IfWinNotExist, ahk_id%value%
      {
         r.Remove(Key)</code></pre></div></blockquote></div><p><strong>For Key, value in r</strong>- цикл по всем элементам массива <strong>r</strong>, ключ будет помещён в переменную <strong>Key</strong>, а значение в <strong>value</strong>. На примере всё понятно:<br /></p><div class="codebox"><pre><code>arr := Array()
arr[&quot;Key1&quot;] := &quot;Value1&quot;
arr[&quot;Key2&quot;] := &quot;Value2&quot;
arr[&quot;Key3&quot;] := &quot;Value3&quot;
For Key, Value in arr
{
   MsgBox %Key%, %Value%
}</code></pre></div><p><strong>r.Remove(Key)</strong>- удаление элемента с ключом <strong>Key</strong> из массива <strong>r</strong>.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-02-07T22:10:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56558#p56558</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56557#p56557" />
			<content type="html"><![CDATA[<p>Да работает.<br />Ничего себе сколько тонкостей и сложностей, казалось бы для простой задачи.<br />Спасибо!<br /></p><div class="codebox"><pre><code>  For Key, value in r
   {
      IfWinNotExist, ahk_id%value%
      {
         r.Remove(Key)</code></pre></div><p>А можете, пожалуйста, вот это объяснить.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T21:36:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56557#p56557</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56549#p56549" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Не, не получается.<br />Открываем первый блокнот, он максимизируется.<br />Мы его сдвигаем.<br />Открываем второй блокнот, он максимизируется.<br />Мы его закрываем.<br />Потом активируем первый и первый опять максимизируется.</p></blockquote></div><p>Пришлось раз 20 повторить, чтобы так и произошло <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />. Похоже разрабы накосячили с массивами, если имена ключей сделать строками, то проблема, вроде, пропадает:<br /></p><div class="codebox"><pre><code>r := Array()
loop
{
   id := 0|WinExist(&quot;A&quot;) ;берём активное окно!
   WinGetTitle, Title, ahk_id%id% ;получаем его заголовок
   if(InStr(Title, &quot;Блокнот&quot;)&amp;&amp;(!r[&quot;_&quot; . id])) ;Если в заголовке есть слово &quot;Блокнот&quot; и окна нет в списке
   {
     Winrestore, ahk_id%id%
      winmove, ahk_id%id%,, 0,0,%a_screenwidth%, %A_ScreenHeight% 
      r[&quot;_&quot; . id] := id
   }
   WinWaitNotActive, ahk_id%id%
   For Key, value in r
   {
      IfWinNotExist, ahk_id%value%
      {
         r.Remove(Key)
      }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-02-07T21:06:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56549#p56549</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56545#p56545" />
			<content type="html"><![CDATA[<p>Не, не получается.<br />Открываем первый блокнот, он максимизируется.<br />Мы его сдвигаем.<br />Открываем второй блокнот, он максимизируется.<br />Мы его закрываем.<br />Потом активируем первый и первый опять максимизируется.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T20:21:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56545#p56545</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56544#p56544" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>r := Array()
loop
{
   id := WinExist(&quot;A&quot;) ;берём активное окно!
   WinGetTitle, Title, ahk_id%id% ;получаем его заголовок
   if(InStr(Title, &quot;Блокнот&quot;)&amp;&amp;(!r[id])) ;Если в заголовке есть слово &quot;Блокнот&quot; и окна нет в списке
   {
     Winrestore, ahk_id%id%
      winmove, ahk_id%id%,, 0,0,%a_screenwidth%, %A_ScreenHeight% 
      r[id] := 1
   }
   WinWaitNotActive, ahk_id%id%
   For Key, value in r
   {
      IfWinNotExist, ahk_id%Key%
      {
         r.Remove(Key)
      }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-02-07T20:12:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56544#p56544</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56543#p56543" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>settitlematchmode 2
r := Array()
loop
{
   WinGet id, id, Notepad, A
   if(!r[id]) ;Есть ли окно в списке
   {
     Winrestore, Notepad  
      winmove, Notepad,, 0,0,%a_screenwidth%, %A_ScreenHeight% 
      r[id] := 1
      ; msgbox % id
   }
   WinWaitNotActive, ahk_id%id% ;ждём пока активным станет другое окно
   For Key, value in r
   {
      IfWinNotExist, ahk_id%Key%
      {
         r.Remove(Key)
      }
   }
}</code></pre></div><p>Если открыть одно окно блокнота и попытаться его минимизировать, то скрипт автоматом его максимизирует.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T19:48:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56543#p56543</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56542#p56542" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p>Конечно, при повторном открытиии окно получает такой же id, а оно уже есть в списке -&gt; скрипт не срабатывает.</p></blockquote></div><p>Этот id никак не зависит от открываемой программы, более того, дескрипторы всех GUI объектов хранятся в одной таблице(HANDLEENTRY), т.е. id окна вполне может достаться, например, хуку или хоткею. Этот список, кстати, спроектирован в каждый процесс. В принципе все эти хендлы являются просто ссылками, поэтому если окно создать, потом удалить и снова создать, то оно получит тот же хэндл, я как-то об этом сразу не подумал. Тогда придётся удалять закрытые окна:<br /></p><div class="codebox"><pre><code>r := Array()
loop
{
   WinGet id, id, A
   if(!r[id]) ;Есть ли окно в списке
   {
      r[id] := 1
	  msgbox % id
   }
   WinWaitNotActive, ahk_id%id% ;ждём пока активным станет другое окно
   For Key, value in r
   {
      IfWinNotExist, ahk_id%Key%
	  {
		 r.Remove(Key)
	  }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-02-07T17:40:39Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56542#p56542</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56541#p56541" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Settitlematchmode 2
r := Array()
loop
{
   WinGet id, id, Notepad, A
   if(!r[id]) ;Есть ли окно в списке
   {
      Winrestore, Notepad  
      winmove, Notepad,, 0,0,%a_screenwidth%, %A_ScreenHeight% 
      r[id] := 1
   }
   WinWaitNotActive, ahk_id%id% ;ждём пока активным станет другое окно
   IfWinNotExist, ahk_id%id%
   r[id] := 0
}</code></pre></div><p>При минимизировании блокнота всё дёргается как припадочное.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T16:47:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56541#p56541</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56540#p56540" />
			<content type="html"><![CDATA[<p>Тогда надо сделать проверку, когда окно стало неактивным - не прекратило ли оно своё существование?<br />Если да - удалить его id из списка. Добавьте в код из #5 после<br /></p><div class="codebox"><pre><code>WinWaitNotActive, ahk_id%id% ;ждём пока активным станет другое окно</code></pre></div><p>Следующие строки:<br /></p><div class="codebox"><pre><code>IfWinNotExist, ahk_id%id%
   r[id] := 0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-02-07T16:28:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56540#p56540</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56539#p56539" />
			<content type="html"><![CDATA[<p>Так это я понимаю. <br />Не при повторном. А при открытии новых, закрытии старых....</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T15:21:43Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56539#p56539</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56538#p56538" />
			<content type="html"><![CDATA[<p>Конечно, при повторном открытиии окно получает такой же id, а оно уже есть в списке -&gt; скрипт не срабатывает.</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-02-07T14:44:50Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56538#p56538</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Принудительно открывать окна на первом мониторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=56535#p56535" />
			<content type="html"><![CDATA[<p>Что-то код этот не всегда срабатывает.<br />Смысл такой. Есть программа Nview, которая привязывает определённую программу к определённому окну при работе с несколькими мониторами.<br />У меня Open Office всегда открывается на втором мониторе.<br />Но когда я захлжу на компьютер удалённо, то я вижу только один монитор, поэтому и решил взяться за изготовление скрипта, который будет документы Open Office перемещать на первый монитор.<br />А в вашем скрипте по-началу работает, а потом если я закрываю окна, потом открываю новые перестает</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2012-02-07T12:59:31Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=56535#p56535</id>
		</entry>
</feed>
