<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Оповещение об активности окна более минуты]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12299</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12299&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Оповещение об активности окна более минуты».]]></description>
		<lastBuildDate>Wed, 11 Jan 2017 07:40:25 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110803#p110803</link>
			<description><![CDATA[<p>Не обратил внимания на то, что процессор сильно нагружался, но с паузой, кажется, такого нет. Вариант от <strong>teadrinker</strong> выглядит лаконичнее, разницы в работе, на первый взгляд, не замечаю. Разве что, нет отображения стечения времени в ToolTip. А это тоже, пожалуй, необходимый функционал. Но лучше не в ToolTip. Я попробовал взять визуальное оформление таймера из этого сценария (кнопка Start/Stop должна ставить на паузу ожидание активности блокнота), но опять же, не получается прикрутить должным образом:<br /></p><div class="codebox"><pre><code>#SingleInstance FORCE

#NoEnv
SetBatchLines, -1
; Some variables
ElapsedTime := A_YYYY                                 ; initialize ElapsedTime, it will be treated as YYYY0101000000
BalanceTime := 0                                      ; initialize BalanceTime (time not counted yet)
; Tray menu
Menu, Tray, NoStandard                                ; clear the tray menu for customizing
Menu, Tray, Add, Quit, AppExit                        ; add item &quot;Quit&quot; to call AppExit
Menu, Tray, Default, Quit                             ; double-click on the tray icon will call &quot;Quit&quot;
Menu, Tray, Tip, % &quot; AHK short-time Stopwatch &quot;       ; add a nice tool tip
; GUI
Gui, +LastFound ; Added
WinSet, TransColor, FFFFFF 100 ; Added
;
Gui, +ToolWindow -Caption +AlwaysOnTop                ; made some changes for relative positioning and sizing
Gui, Margin, 0, 0                                     ; http://l.autohotkey....ui.htm#Position
Gui, Font, S32 CDefault Bold, Verdana
Gui, Add, Text, Center vDisplayTime, 00:00
Gui, Font, S12, Verdana
Gui, Add, Button, x+0 yp w60 hp vBtnStartStop gStartStop Default, Start`nStop
Gui, Add, Button, x+0 yp w60 hp vBtnReset gReset, Reset
Gui, Add, Button, x+0 yp w60 hp gAppExit, Quit
Gui, Show, , Stop Watch
Gosub, StartStop
Return
; Exit label
AppExit:
ExitApp
; BtnStartStop label
StartStop:
   GuiControlGet, BtnStartStop                        ; get the caption of the button
   If (BtnStartStop = &quot;Start`nStop&quot;) {                ; if it is &quot;Start`nStop&quot;
      StartTickCount := A_TickCount - BalanceTime     ; initialize StartTickCount
      SetTimer, StopWatch, 10                         ; start the timer called every 10 ms to be accurate
      GuiControl, , BtnStartStop, Stop                ; set the caption to Stop
   } Else {                                           ; it should be &quot;Stop&quot;
      BalanceTime := A_TickCount - StartTickCount     ; memorize the balance time not counted yet
      SetTimer, StopWatch, Off                        ; stop the timer
      GuiControl, , BtnStartStop, Start`nStop         ; set the caption to &quot;Start`nStop&quot;
   }
Return
; BtnReset label
Reset:
   SetTimer, StopWatch, Off                           ; stop the timer
   GuiControl, , BtnStartStop, Start`nStop            ; set the caption of BtnStartStop to &quot;Start`nStop&quot;
   GuiControl, , DisplayTime, 00:00                   ; initialize DisplayTime
   ElapsedTime := A_YYYY                              ; initialize ElapsedTime, it will be treated as YYYY0101000000
   BalanceTime := 0                                   ; initialize BalanceTime
   GuiControl, Focus, BtnStartStop                    ; set the focus on BtnStartStop
   GuiControl, -Default, BtnReset                     ; remove the BS_DEFPUSHBUTTON (default) style
   GuiControl, +Default, BtnStartStop                 ; set the BS_DEFPUSHBUTTON (default) style
Return
; Timer routine
StopWatch:
   If ((A_TickCount - StartTickCount) &gt;= 1000) {      ; if current tickcount - StartTickCount &gt;= 1000 (i.e. 1 second)
      StartTickCount += 1000                          ; add 1000 ms (1 second) to StartTickCount
      ElapsedTime += 1, S                             ; add 1 second to ElapsedTime
      FormatTime, DisplayTime, %ElapsedTime%, mm:ss   ; format ElapsedTime to mm:ss
      GuiControl, , DisplayTime, %DisplayTime%        ; update DisplayTime
   }
Return</code></pre></div><p>Помогите это сделать, пожалуйста.</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Wed, 11 Jan 2017 07:40:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110803#p110803</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110802#p110802</link>
			<description><![CDATA[<p>По-моему, вариант malcev`a работает немного лучше.</p>]]></description>
			<author><![CDATA[null@example.com (svoboden)]]></author>
			<pubDate>Wed, 11 Jan 2017 05:51:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110802#p110802</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110800#p110800</link>
			<description><![CDATA[<p>Циклом так проще:<br /></p><div class="codebox"><pre><code>ActiveTime := 5  ; в секундах
winClass := &quot;ahk_class Notepad&quot;
ElapsedTime := 0

Loop  {
   WinWaitActive, % winClass
   StartTime := A_TickCount/1000 - ElapsedTime
   WinWaitNotActive,,, ActiveTime - ElapsedTime
   if ErrorLevel  {
      MsgBox, TimeOut
      ExitApp
   }
   ElapsedTime := A_TickCount/1000 - StartTime
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 11 Jan 2017 05:15:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110800#p110800</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110799#p110799</link>
			<description><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Ты имеешь в виду, то что процессор нагружает?</p></blockquote></div><p>Конечно. Подход тоже не айс — постоянный цикл, но зависит, должен ли скрипт что-то ещё делать.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 11 Jan 2017 03:54:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110799#p110799</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110798#p110798</link>
			<description><![CDATA[<p>Ты имеешь в виду, то что процессор нагружает? Добвил sleep.<br />Или сам подход?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 11 Jan 2017 03:35:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110798#p110798</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110797#p110797</link>
			<description><![CDATA[<p><strong>Malcev</strong>, ужас, не надо так.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 11 Jan 2017 03:22:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110797#p110797</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110796#p110796</link>
			<description><![CDATA[<p><strong>Malcev</strong>, то, что нужно! Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Wed, 11 Jan 2017 00:36:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110796#p110796</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110794#p110794</link>
			<description><![CDATA[<div class="codebox"><pre><code>ElapsedTime := 0
loop
{
   WinWaitActive, ahk_class Notepad
   StartTime := A_TickCount - ElapsedTime
   loop
   {
      tooltip % ElapsedTime
      IfWinNotActive, ahk_class Notepad
         break
      ElapsedTime := A_TickCount - StartTime
      if (ElapsedTime &gt; 60000)
      {
         MsgBox % ElapsedTime
         return
      }
      sleep 10
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 11 Jan 2017 00:23:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110794#p110794</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110793#p110793</link>
			<description><![CDATA[<p>При активности 11 секунд срабатывает:<br /></p><div class="codebox"><pre><code>WinWait, ahk_class Notepad

all_time := &quot;18&quot; ; 18 - это 11 секунд
start_time := A_TickCount
all_time := (start_time+all_time*600) 

Loop 
{
var := (all_time-A_TickCount)       
if var &lt;= 0 
break
}

MsgBox  12
return
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (svoboden)]]></author>
			<pubDate>Wed, 11 Jan 2017 00:16:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110793#p110793</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110792#p110792</link>
			<description><![CDATA[<p><strong>svoboden</strong>, Спасибо! Вопрос один, имелось в виду желание расширить функционал, а именно добавить возможность складывать общее времмя активности окна.</p><p>Протестировал Ваш вариант, но не понял, как его использовать. Сценарий каждую секунду выдает оповещение о наличии окна. Необходимо лишь тогда, когда окно активно более заданного времени.</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Tue, 10 Jan 2017 23:09:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110792#p110792</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110791#p110791</link>
			<description><![CDATA[<p>По первому вопросу. Так может:<br /></p><div class="codebox"><pre><code>loop{
WinWait, ahk_class Notepad
StartTime := A_TickCount
Sleep, 1000
ElapsedTime := A_TickCount - StartTime
if (ElapsedTime &lt; 60000)
	MsgBox % ElapsedTime
}
return</code></pre></div><p>По второму, не вникал особо.</p>]]></description>
			<author><![CDATA[null@example.com (svoboden)]]></author>
			<pubDate>Tue, 10 Jan 2017 23:01:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110791#p110791</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Оповещение об активности окна более минуты]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110782#p110782</link>
			<description><![CDATA[<p>Подскажите, пожалуйста, как добавить оповещение об активности окна более минуты? Было бы идеально, если сценарий умел складывать время активности заданного окна при прерывании или периодичной активности.</p><p>Такой вариант не работает:<br /></p><div class="codebox"><pre><code>loop{
WinWait, ahk_class notepad
StartTime := A_TickCount
ElapsedTime := A_TickCount - StartTime
if (ElapsedTime &gt; 60000)
	MsgBox % ElapsedTime
}
return
</code></pre></div><p>У меня есть сценарий, который отображает общее время копирования/перемещения, если оно происходило более трех минут. Но не могу понять, как правильно его модифицировать под текущую задачу.<br /></p><div class="codebox"><pre><code>SetTimer, WaitCopying, 100
WaitCopying:
winName:=&quot;ahk_class OperationStatusWindow&quot;
while !(WinExist(winName))
	Sleep, 250
	StartTime := A_TickCount
WinWaitClose, %winName%
ElapsedTime := A_TickCount - StartTime
if (ElapsedTime &gt; 180000) ; 3 min
	{
	ElapsedTimeConvert := SecToHHMMSS(ElapsedTime // 1000)
	MsgBox, , File System, Copying is Finished!`nElapsed time: %ElapsedTimeConvert%
}
return

SecToHHMMSS(Sec) {
	OldFormat := A_FormatFloat
	SetFormat, Float, 02.0
	Hrs  := Sec//3600/1
	Min := Mod(Sec//60, 60)/1
	Sec := Mod(Sec,60)/1
	SetFormat, Float, %OldFormat%
	Return (Hrs ? Hrs &quot;:&quot; : &quot;&quot;) Min &quot;:&quot; Sec
}

</code></pre></div><p>Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (becauseim)]]></author>
			<pubDate>Tue, 10 Jan 2017 16:31:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110782#p110782</guid>
		</item>
	</channel>
</rss>
