<?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=9768&amp;type=atom" />
	<updated>2014-07-04T10:24:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9768</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84500#p84500" />
			<content type="html"><![CDATA[<p>Странный вопрос, нигде не меняет. <br />Судя по комментарию в коде из шапки, ТС это не озадачит.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-07-04T10:24:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84500#p84500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84499#p84499" />
			<content type="html"><![CDATA[<p>А где в коде value меняет свое значение?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-07-04T09:50:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84499#p84499</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84498#p84498" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Как сделать что бы скриншоты делались каждые пол секунды на протяжении 10 секунд?</p></blockquote></div><p>Не проще привязать к количеству действий?<br /></p><div class="codebox"><pre><code>
Loop 20
{
    WinWaitActive, ahk_class Notepad
    ToolTip % A_Index
    sleep 500
}
</code></pre></div><p>Но если к 10 секундам, то проще наверное так:<br /></p><div class="codebox"><pre><code>
value := 0

Loop
{
    If (value != 0) ; Если value неравно 0
        Continue ; То снова проверяем его значение
        
    passed := 0 
    
    While passed &lt; 10000
    {
        WinWaitActive, ahk_class Notepad
        start := A_TickCount
        ToolTip % A_Index &quot;`n&quot; passed
        Sleep 500  
        passed += A_TickCount - start
    }
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-07-04T09:39:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84498#p84498</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84495#p84495" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Settitlematchmode, 2
loop
{
   IfWinActive, Notepad
   {  
      start_time := A_TickCount
      msgbox % finish_time
      loop
      { 
         ToolTip 123
         if (finish_time + A_TickCount - start_time) &gt; 10000
         {
            msgbox done
            ExitApp
         }
         IfWinNotActive, Notepad
         {
            finish_time += A_TickCount - start_time
            break
         }
      }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-07-04T08:05:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84495#p84495</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84490#p84490" />
			<content type="html"><![CDATA[<p>Я бы хотел бы что скрины делались, когда окно активно в течении 10 секунд.<br />Например активировал окно, скрины делаются, через 6 секунд свернул окно, скрины перестали делаться и далее опять развернул окно, и скрины опять начались делаться, но остальные 4 секунды.<br />Поэтому не понимаю зачем время вычитать</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-04T05:36:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84490#p84490</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84488#p84488" />
			<content type="html"><![CDATA[<p>Не понимаю, что вы хотите добиться, но если вы хотите чтобы время засекалось только в активированном окне, то можете при активации этого окна прибавлять время и при деактивации&nbsp; &nbsp;его вычитать.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-07-04T00:28:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84488#p84488</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84486#p84486" />
			<content type="html"><![CDATA[<p>Если так:</p><div class="codebox"><pre><code>#Include GDIp.ahk
start_time := A_TickCount
Loop
   {
      sleep 250
      file = %A_TickCount%screen.png
      Screenshot(file)
      if (D := A_TickCount - start_time) &gt; 2000
         break 
ToolTip, %D%, 425, 250, 1
   }
return

F3::
exitapp
return

Screenshot(outfile)
{
    pToken := Gdip_Startup()

    screen=0|0|%A_ScreenWidth%|%A_ScreenHeight%
    pBitmap := Gdip_BitmapFromScreen(screen)

    Gdip_SaveBitmapToFile(pBitmap, outfile, 100)
    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
}</code></pre></div><p>то нормально, делает 5 скринов.<br />А если так:<br /></p><div class="codebox"><pre><code>#Include GDIp.ahk
start_time := A_TickCount
Loop
   {
     IfWinActive, Калькулятор Плюс
      {
      sleep 250
      file = %A_TickCount%screen.png
      Screenshot(file)
      if (D := A_TickCount - start_time) &gt; 2000
         break 
ToolTip, %D%, 425, 250, 1
      }
   }
return

F3::
exitapp
return

Screenshot(outfile)
{
    pToken := Gdip_Startup()

    screen=0|0|%A_ScreenWidth%|%A_ScreenHeight%
    pBitmap := Gdip_BitmapFromScreen(screen)

    Gdip_SaveBitmapToFile(pBitmap, outfile, 100)
    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
}</code></pre></div><p>то делает 1 скрин, когда активируешь окно. Как исправить?</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-03T22:40:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84486#p84486</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84484#p84484" />
			<content type="html"><![CDATA[<p>Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-03T21:59:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84484#p84484</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84482#p84482" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>start_time := A_TickCount
loop
{
   tooltip, 123
   if (A_TickCount - start_time) &gt; 10000
      break
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-07-03T20:33:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84482#p84482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84481#p84481" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Впихнуть это все в цикл и и выходить из него когда A_TickCount - стартовое время &gt; 10000</p></blockquote></div><p>Я так понял что имеется виду это:<br /></p><div class="codebox"><pre><code>start_time := A_TickCount
Sleep, 1000
elapsed_time := A_TickCount - start_time
MsgBox, прошло %elapsed_time% миллисекунд.
</code></pre></div><p>Я вот уже час пытаюсь и ничего не выходит(</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-03T20:22:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84481#p84481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84478#p84478" />
			<content type="html"><![CDATA[<p>Впихнуть это все в цикл и и выходить из него когда A_TickCount - стартовое время &gt; 10000</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-07-03T18:43:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84478#p84478</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Завершения цикла(таймера) через определенное время]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84477#p84477" />
			<content type="html"><![CDATA[<p>Здрасте. Ниже кусочек кода моего скрипта.<br /></p><div class="codebox"><pre><code>#Include Gdip.ahk

F3::ExitApp

value := 0

SetTimer CheckExist, 500

Checkexist:
Process, Exist, process.exe
status = %ErrorLevel% 
if status = 0 
{ 
MsgBox, Запустите  приложение
exitapp 
}
else

;Дальше тут идет чтение памяти приложения и если оно по определенному адресу становится равно 0 то начинаются делаться скрины. Для удобства я сразу присвоил переменой value = 0

if (value = 0)
{
file = %a_tickcount%screen.png
Screenshot(file)
}
else if (value = 1)
{
}
return

Screenshot(outfile)
{
    pToken := Gdip_Startup()

    screen=0|0|%A_ScreenWidth%|%A_ScreenHeight%
    pBitmap := Gdip_BitmapFromScreen(screen)

    Gdip_SaveBitmapToFile(pBitmap, outfile, 100)
    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
}
</code></pre></div><p>Скриншоты делаются каждые пол секунды. Как сделать что бы скриншоты делались каждые пол секунды на протяжении 10 секунд? И по истечении 10 сек либо происходит exitapp или начинает заново считывать переменную value с целью узнать вдруг там уже 1, а не 0. У меня уже дым из ушей идет, не могу решить данную проблему. Помогите пожалуйста.</p><p>P.S. Нужен инклуд GDIp. Его можно скачать по этой ссылку <a href="http://www.autohotkey.net/~tic/Gdip.ahk">http://www.autohotkey.net/~tic/Gdip.ahk</a></p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-03T18:03:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84477#p84477</id>
		</entry>
</feed>
