<?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=14510&amp;type=atom" />
	<updated>2019-01-25T05:14:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14510</id>
		<entry>
			<title type="html"><![CDATA[AHK: Подсчет нажатий в окнах разных программ с учетом даты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=131590#p131590" />
			<content type="html"><![CDATA[<p>Добрый день.<br />Подскажите - как объединить два скрипта.</p><p>Первый скрипт - учитывает нажатия клавиш, в определенной программе (как я поняла - это либо Блокнот, либо Тотал Коммандер)<br /></p><div class="codebox"><pre><code>
Loop 255
   Hotkey, % &quot;~vk&quot; . Format(&quot;{:X}&quot;, A_Index), WatchPress, On
Return

WatchPress()  {
   static obj := { TTOTAL_CMD: {text: &quot;Total Commander&quot;, count: 0}, Notepad: {text: &quot;Блокнот&quot;, count: 0} }
   Critical
   WinGetClass, winClass, A
   if winClass not in TTOTAL_CMD,Notepad
      Return
   
   obj[winClass, &quot;count&quot;]++
   for k, v in obj
      text .= (text = &quot;&quot; ? &quot;&quot; : &quot;`r`n&quot;) . v.text . &quot; -&quot; . v.count
   Sort, text
   
   oFile := FileOpen(A_ScriptDir . &quot;\1.txt&quot;, &quot;w&quot;)
   oFile.Write(text)
   oFile.Close()
}
</code></pre></div><p>Второй скрипт просто подсчитывает нажатия клавиш, за текущий день.<br /></p><div class="codebox"><pre><code>
storage := A_ScriptDir . &quot;\16.txt&quot;
template := &quot;Нажато клавиш: &quot;

WatchPress := Func(&quot;WatchPress&quot;).Bind(storage, template)
Loop 248
   Hotkey, % &quot;~&quot; . Format(&quot;vk{:X}&quot;, A_Index + 7), % WatchPress, On
Return

WatchPress(filePath, template)  {
   Critical
   date := A_DD . &quot;.&quot; . A_MM . &quot;.&quot; . A_YEAR
   oFile := FileOpen(filePath, &quot;rw&quot;, &quot;cp0&quot;)
   content := oFile.Read()
   RegExMatch(content, &quot;s)(.*\R)?\K.*?(?&lt;PressCount&gt;\d+)\s(?&lt;Date&gt;\d\d\.\d\d\.\d{4})$&quot;, lastStr)
   dateFit := date = lastStrDate
   newLastStr := ( (lastStr &amp;&amp; !dateFit) ? &quot;`r`n&quot; : &quot;&quot; ) . template . (dateFit ? ++lastStrPressCount : &quot;1&quot; ) . &quot; &quot; . date
   if dateFit
      oFile.Pos -= StrLen(lastStr), oFile.Length := oFile.Pos
   oFile.Write(newLastStr)
   oFile.Close()
}
</code></pre></div><p>У меня вопрос - как провести запись в txt с учетом и окна программы и текущей даты ?<br />Навроде <br />08.01.2019<br />Total Commander -100<br />Блокнот -45<br />29.01.2019<br />Total Commander -75<br />Блокнот -19<br />...</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-01-25T05:14:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=131590#p131590</id>
		</entry>
</feed>
