<?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=12299&amp;type=atom" />
	<updated>2017-01-11T07:40:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12299</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110803#p110803" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-01-11T07:40:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110803#p110803</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110802#p110802" />
			<content type="html"><![CDATA[<p>По-моему, вариант malcev`a работает немного лучше.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2017-01-11T05:51:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110802#p110802</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110800#p110800" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-11T05:15:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110800#p110800</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110799#p110799" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Ты имеешь в виду, то что процессор нагружает?</p></blockquote></div><p>Конечно. Подход тоже не айс — постоянный цикл, но зависит, должен ли скрипт что-то ещё делать.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-11T03:54:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110799#p110799</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110798#p110798" />
			<content type="html"><![CDATA[<p>Ты имеешь в виду, то что процессор нагружает? Добвил sleep.<br />Или сам подход?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-11T03:35:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110798#p110798</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110797#p110797" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, ужас, не надо так.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-11T03:22:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110797#p110797</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110796#p110796" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, то, что нужно! Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-01-11T00:36:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110796#p110796</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110794#p110794" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-11T00:23:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110794#p110794</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110793#p110793" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2017-01-11T00:16:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110793#p110793</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110792#p110792" />
			<content type="html"><![CDATA[<p><strong>svoboden</strong>, Спасибо! Вопрос один, имелось в виду желание расширить функционал, а именно добавить возможность складывать общее времмя активности окна.</p><p>Протестировал Ваш вариант, но не понял, как его использовать. Сценарий каждую секунду выдает оповещение о наличии окна. Необходимо лишь тогда, когда окно активно более заданного времени.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-01-10T23:09:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110792#p110792</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110791#p110791" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2017-01-10T23:01:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110791#p110791</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Оповещение об активности окна более минуты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110782#p110782" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2017-01-10T16:31:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110782#p110782</id>
		</entry>
</feed>
