<?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="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5916&amp;type=atom" />
	<updated>2011-06-23T22:38:06Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5916</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49380#p49380" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>s := VarSetCapacity(a, 4096)
loopcount := 5
myhotkey := &quot;F&quot;5
Gosub,Read
Gosub,TrayMenu
Gosub,Settings
Return

Read:
   If myhotkey Not In F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12
   ,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
   ,а,б,в,г,д,е,ё,ж,з,и,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ъ,ы,ь,э,ю,я
   ,1,2,3,4,5,6,7,8,9,0,-,=,*,/,\,[,]
      {
         myhotkey := &quot;F&quot;5
         Gosub, Settings
      }
   If myhotkey =
      {
         myhotkey := &quot;F&quot;5
         Gosub, Settings
      }
   If (loopcount = &quot;0&quot; || loopcount = &quot;&quot;)
      {
         loopcount := 5
         Gosub, Settings
      }
   hotkeydown = *%myhotkey%
   Hotkey, %hotkeydown%, HotkeyLabel, On
   Return

HotkeyLabel:
   Loop, % loopcount
      { ; собственно это переработанный 4тый пример из описания по комманде Process
         DllCall(&quot;Psapi.dll\EnumProcesses&quot;
                , &quot;UInt&quot;, &amp;a
                   , &quot;UInt&quot;, s
                      , &quot;UIntP&quot;, r)
         Loop, % r // 4
            {
               id := NumGet(a, A_Index * 4)
               h := DllCall(&quot;OpenProcess&quot;
                           , &quot;UInt&quot;, 0x0010 | 0x0400
                              , &quot;Int&quot;, false
                                 , &quot;UInt&quot;, id)
               VarSetCapacity(n, 4096, 0)
               e := DllCall(&quot;Psapi.dll\GetModuleBaseNameA&quot;
                           , &quot;UInt&quot;, h
                              , &quot;UInt&quot;, 0
                                 , &quot;Str&quot;, n
                                    , &quot;UInt&quot;, s)
               DllCall(&quot;CloseHandle&quot;, &quot;UInt&quot;, h)
               If (n &amp;&amp; e &amp;&amp; n = &quot;mstsc.exe&quot;)
                  {
;                     WinActivate, % &quot;ahk_pid&quot; id ; вариант 1 - активация всех найденых окон
                     WinWaitActive, % &quot;ahk_pid&quot; id ; вариант 2 - ожидание активации найденых окон
                     Send, {Enter}
                  }
            }
      }
   KeyWait, % myhotkey
   Return
 
SettingsOK:
   Gui, Submit
   Gosub, Read
   Return
 
Settings:
   Hotkey, %hotkeydown%, HotkeyLabel, Off
   Gui, Destroy
   Gui, Font, Courier New
   Gui, Add, Edit, vmyhotkey x12 y10 w20 h20 , % myhotkey
   Gui, Add, Edit, vloopcount x12 y40 w20 h20 , % loopcount
   Gui, Add, Button, gSettingsCancel x72 y70 w50 h20 , &amp;Cancel
   Gui, Add, Text, x42 y10 w100 h20 , choose desired key
   Gui, Add, Text, x42 y40 w140 h20 , select count of loops
   Gui, Add, Button, gSettingsOK x12 y70 w50 h20 , &amp;OK
   Gui, Add, Button, gExit x132 y70 w50 h20 , &amp;Exit
   Gui, Show, Center h106 w187, Settings
   Return
 
TrayMenu:
   Menu, Tray, NoStandard
   Menu, Tray, Add, &amp;Settings, Settings
   Menu, Tray, Add, &amp;About, About
   Menu, Tray, Add, &amp;Exit, Exit
   Return
 
SettingsCancel:
   Gui, Destroy
   Hotkey, %hotkeydown%, HotkeyLabel, On
GuiClose: ; закрыть на крестик не получится, надо делать выбор: ок, отмена или выход :)
   Return

About:
   Gui, 99:Font, CBlue Underline
   Gui, 99:Add, Text, y+5 gGoAutoHotKey, www.autohotkey.com
   Gui, 99:Font
   Gui, 99:+AlwaysOnTop
   Gui, 99:Show, Center
   Return

GoAutoHotKey:
   Run, http://www.autohotkey.com,, UseErrorLevel
   Return

Exit:
   Gui, Destroy
   ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-06-23T22:38:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49380#p49380</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49342#p49342" />
			<content type="html"><![CDATA[<p>Нет, ентер ничего не закрывает. Он просто дает старт некоторым действиям в окне, а альт+таб переключает окно на другое. Нужно сделать так, чтобы после команды &quot;альт+таб&quot; &quot; скрипт подождал активации следующего окна. Все окна имеют разные названия и разные процессы в диспетчере задач, но эти процессы называются одинаково.</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-23T09:48:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49342#p49342</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49334#p49334" />
			<content type="html"><![CDATA[<p>В момент симуляции первого нажатия Enter&#039;а дочернее окно закрывается, а родительское (основное окно программы) остаётся активным, или Enter закрывает основное окно, через какой-то период времени появляется окно от этой же программы, где следует сделать вторую симуляцию нажатия Enter&#039;а?</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-06-23T05:40:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49334#p49334</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49312#p49312" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Grey пишет:</cite><blockquote><p>2 <strong>TIGRUS</strong> Не понятно, поясните точнее.</p></blockquote></div><p>Сейчас скрипт делает это определенное количество раз без ожидания активации окна.<br /></p><div class="codebox"><pre><code>send {Enter}
Sleep, 50
send !{Tab}</code></pre></div><p>Нужно сделать так, чтобы скрипт исполнил это<br /></p><div class="codebox"><pre><code>send {Enter}
Sleep, 50
send !{Tab}</code></pre></div><p>и подождал, пока активируется следующее окно. После каждого цикла окно меняется и соответственно меняется его название. Как заставить скрипт ждать активации окна? (все окна одной программы, так сказать. их процессы в диспетчера задач разные, но имеют одинаковые название - mstsc ) Или как узнать универсальное имя для этих окон? В общем, нужно сделать так:</p><div class="codebox"><pre><code>send {Enter}
Sleep, 50
send !{Tab}
WinWaitActive, Название окна, 0</code></pre></div><p>Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-22T14:24:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49312#p49312</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49309#p49309" />
			<content type="html"><![CDATA[<p>2 <strong>TIGRUS</strong> Не понятно, поясните точнее.</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-06-22T13:51:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49309#p49309</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49303#p49303" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>TIGRUS</strong>, избегайте <strong>излишнего</strong> цитирования.</span></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-06-22T05:50:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49303#p49303</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49300#p49300" />
			<content type="html"><![CDATA[<p>Огромное спасибо! Возник еще один вопрос. </p><p>Как сделать так, чтобы после после повтора скрипт подождал, пока активируется следующее окно, если все окна имеют разные названия?</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-21T22:17:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49300#p49300</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49195#p49195" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>TIGRUS пишет:</cite><blockquote><p>Знаю, что надо для этого использовать Smart GUI Creator...</p></blockquote></div><p>Очень удобный <em>иструмент</em>.<br /></p><div class="codebox"><pre><code>loopcount := 5
myhotkey = F5
Gosub,Read
Gosub,TrayMenu
Gosub,Settings
Return

Read:
   If myhotkey Not In F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12
   ,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
   ,а,б,в,г,д,е,ё,ж,з,и,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ъ,ы,ь,э,ю,я
   ,1,2,3,4,5,6,7,8,9,0,-,=,*,/,\,[,]
      {
         myhotkey = F5
         Gosub, Settings
      }
   If myhotkey =
      {
         myhotkey = F5
         Gosub, Settings
      }
   If loopcount =
      {
         loopcount := 5
         Gosub, Settings
      }
   hotkeydown = *%myhotkey%
   Hotkey, %hotkeydown%, HotkeyLabel, On
   Return

HotkeyLabel:
   Loop, % loopcount
      {
         Send {Enter}
         Sleep, 50 ; время подбираете по вкусу
         Send !{Tab}
      }
   KeyWait, % myhotkey
   Return

SettingsOK:
   Gui, Submit
   Gosub, Read
   Return

Settings:
   Hotkey, %hotkeydown%, HotkeyLabel, Off
   Gui, Destroy
   Gui, Font, Courier New
   Gui, Add, Edit, vmyhotkey x12 y10 w20 h20 , % myhotkey
   Gui, Add, Edit, vloopcount x12 y40 w20 h20 , % loopcount
   Gui, Add, Button, gSettingsCancel x72 y70 w50 h20 , &amp;Cancel
   Gui, Add, Text, x42 y10 w100 h20 , назначаем хоткей
   Gui, Add, Text, x42 y40 w140 h20 , задаем число повторений
   Gui, Add, Button, gSettingsOK x12 y70 w50 h20 , &amp;OK
   Gui, Add, Button, gExit x132 y70 w50 h20 , &amp;Exit
   Gui, Show, xCenter yCenter h106 w187, Settings
   Return

TrayMenu:
   Menu, Tray, NoStandard
   Menu, Tray, Add, &amp;Settings, Settings
   Menu, Tray, Add, &amp;Exit, Exit
   Return

SettingsCancel:
   Gui, Destroy
   Hotkey, %hotkeydown%, HotkeyLabel, On
GuiClose: ; закрыть на крестик не получится, надо делать выбор : ok, cancel или exit :)
   Return

Exit:
   Gui, Destroy
   ExitApp</code></pre></div><p>Если выбран не корректный хоткей в поле ввода, или в случае если поля ввода пустые, происходит сброс на <em>дефолт</em>.</p><div class="quotebox"><cite>TIGRUS пишет:</cite><blockquote><p>Как зациклить данный скрипт?</p></blockquote></div><p><a href="http://www.autohotkey.com/docs/commands/Loop.htm">Loop (normal)</a></p><div class="quotebox"><cite>TIGRUS пишет:</cite><blockquote><p>И как заставить программу ждать, пока окно активируется?</p></blockquote></div><p><a href="http://www.script-coding.com/AutoHotkey/WinWaitActive.html">WinWaitActive</a>.</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-06-18T22:14:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49195#p49195</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49193#p49193" />
			<content type="html"><![CDATA[<p>ps. Как зациклить данный скрипт? Т.е. сделать так, чтобы он повторялся заданное количество раз?<br />И как заставить программу ждать, пока окно активируется?</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-18T12:49:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49193#p49193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49192#p49192" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Команда <a href="http://script-coding.com/AutoHotkey/Send.html"><em>Send</em></a> тебе в помощь!</p></blockquote></div><p>Спасибо. Немного разобрался. Теперь хотелось бы сделать с этого небольшую программку с полем для ввода количества повтора данного скрипта и кнопкой &quot;Старт&quot;. </p><p>Знаю, что надо для этого использовать Smart GUI Creator, но негде не могу найти подробный мануал. Если не сложно, скажите, пожалуйста, что надо дописать до скрипта, чтобы сделать то, о чем я написал выше.</p><p>Собственно, сам скрипт:<br /></p><div class="codebox"><pre><code>send {Enter}
send !{Tab}</code></pre></div><p>Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-18T11:35:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49192#p49192</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49180#p49180" />
			<content type="html"><![CDATA[<p>Команда <a href="http://script-coding.com/AutoHotkey/Send.html"><em>Send</em></a> тебе в помощь!</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-06-17T23:59:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49180#p49180</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Переход от одного окна к другому и нажатие кнопки в каждом окне]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49179#p49179" />
			<content type="html"><![CDATA[<p>Ребята, помогите. Я в АХК 0! Мне нужен скриптик, который будет делать следующее:<br />1. Клик ентер в активном окне<br />2. Переход к следующему окну путем нажатия alt+tab<br />3. Клик ентер<br />4. Переход к следующему окну путем нажатия alt+tab<br />5. Клик ентер</p><p>И так несколько раз. Главное - чтобы все делалось очень быстро, а количество кликов можно было выбрать вручную.</p><p>Спасибо огромное за помощь!</p>]]></content>
			<author>
				<name><![CDATA[TIGRUS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27027</uri>
			</author>
			<updated>2011-06-17T22:56:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49179#p49179</id>
		</entry>
</feed>
