Что нового

Чтение [title] активного окна и запись в txt

Zoldan

Новичок
Сообщения
8
Репутация
0
Приветствую всех.
Как реализовать средствами autoit чтение и запись в txt [title] активного в данный момент окна как в AutoIt Window Info?
Тоесть нужно считать [title] когда окно активно, писать в txt и ожидать следующее окно, и при каждом новом окне писать в txt.
 

zlo-kazan

Скриптер
Сообщения
374
Репутация
100
Код:
#include <date.au3>
HotKeySet("^q","quit")

$file = FileOpen("test.txt", 2)

$activ=""
While 1
	
$var = WinList()

For $i = 1 to $var[0][0]
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsActiv($var[$i][1]) and $activ<>$var[$i][1] Then
	FileWriteLine($file, @HOUR & ":" & @MIN & ":" & @SEC & "  Title=" & $var[$i][0] & "   " & "Handle=" & $var[$i][1])
	$activ=$var[$i][1]
  EndIf
Next
WEnd

FileClose($file)



Func quit()
	FileClose($file)
	exit
EndFunc

Func IsActiv($handle)
  If BitAnd( WinGetState($handle), 8 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Zoldan
Можно еще так попробовать:
Код:
#NoTrayIcon
$sToday = @MDAY & '_' & @MON & '_' & StringRight(@YEAR, 2)
$sFile = @ScriptDir & '\' & $sToday & '.txt'
$sOldTitle = ''
$iCount = 1

HotKeySet('{Esc}', '_Exit')

While 1
	$aWinList = WinList('[ACTIVE]')
	If BitAND(WinGetState($aWinList[1][1]), 2) Then
		If $aWinList[1][0] And $aWinList[1][0] <> 'Program Manager' Then
			If $sOldTitle <> $aWinList[1][0] Then
				$sOldTitle = $aWinList[1][0]
				$sNow = @HOUR & ':' & @MIN & ':' & @SEC
				If Not FileExists($sFile) Then $iCount = 1
				FileWriteLine($sFile, $iCount & '. ' & $sNow & ' Title Active Window: ' & $sOldTitle)
				$iCount += 1
			EndIf
		EndIf
	EndIf
	Sleep(50)
WEnd

Func _Exit()
	Exit
EndFunc   ;==>_Exit
 

SyDr

Сидра
Сообщения
651
Репутация
158
Код:
HotKeySet('{Esc}', '_Exit')
Dim $sTitle, $sTitleP
While True
	$sTitle = WinGetTitle("[ACTIVE]")
	If $sTitle <> $sTitleP Then FileWriteLine("log.txt", $sTitle)
	$sTitleP = $sTitle
	Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc
 
Автор
Z

Zoldan

Новичок
Сообщения
8
Репутация
0
Решение найдено, всем спасибо за ответы.
 
Верх