99 lines
2.3 KiB
Plaintext
99 lines
2.3 KiB
Plaintext
{*******************************************************}
|
|
{ }
|
|
{ ThdCollectWindowInfo }
|
|
{ }
|
|
{ Copyright (C) 2022 kku }
|
|
{ }
|
|
{*******************************************************}
|
|
|
|
unit ThdCollectWindowInfo;
|
|
|
|
interface
|
|
|
|
uses
|
|
Tocsg.Thread, System.SysUtils, System.Classes, Winapi.Windows;
|
|
|
|
type
|
|
TThdCollectWindowInfo = class(TTgThread)
|
|
protected
|
|
procedure Execute; override;
|
|
public
|
|
Constructor Create;
|
|
end;
|
|
|
|
function ExtrWindowTitleAll: String;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Tocsg.Process, Tocsg.Safe, Tocsg.Strings, Tocsg.WndUtil, Tocsg.Path,
|
|
Tocsg.Capture;
|
|
|
|
function ExtrWindowTitleAll: String;
|
|
var
|
|
HwndList: TStringList;
|
|
PList: TTgProcessList;
|
|
i, c: Integer;
|
|
sPName,
|
|
sTitle,
|
|
sTitles: String;
|
|
h, hActive: HWND;
|
|
bActive: Boolean;
|
|
begin
|
|
Result := '';
|
|
Guard(HwndList, TStringList.Create);
|
|
Guard(PList, TTgProcessList.Create);
|
|
PList.UpdateProcessList;
|
|
|
|
hActive := GetForegroundWindow;
|
|
for i := 0 to PList.Count - 1 do
|
|
begin
|
|
bActive := false;
|
|
// sPName := PList[i].sModuleFileName;
|
|
sPName := PList[i].sModuleBaseName;
|
|
|
|
// sTitles := GetWindowCaption(GetWndHandleFromPID(PList[i].dwProcessID));
|
|
sTitles := '';
|
|
if GetWndHandlesFromPID(PList[i].dwProcessID, HwndList) > 0 then
|
|
begin
|
|
sTitle := '';
|
|
for c := 0 to HwndList.Count - 1 do
|
|
begin
|
|
h := StrToInt64Def(HwndList[c], 0);
|
|
if IsWindowVisible(h) then
|
|
begin
|
|
bActive := bActive or (h = hActive);
|
|
sTitle := GetWindowCaption(h);
|
|
if sTitle <> '' then
|
|
SumString(sTitles, sTitle, ' | ');
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
// if sTitles = '' then
|
|
// sTitles := 'Unknown';
|
|
|
|
if sTitles <> '' then
|
|
begin
|
|
if bActive then
|
|
SumString(Result, Format('>>> [%s] %s - %s', [DateTimeToStr(PList[i].dtStart), sPName, sTitles]), #13#10)
|
|
else
|
|
SumString(Result, Format('[%s] %s - %s', [DateTimeToStr(PList[i].dtStart), sPName, sTitles]), #13#10);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
{ TThdCollectWindowInfo }
|
|
|
|
Constructor TThdCollectWindowInfo.Create;
|
|
begin
|
|
Inherited Create;
|
|
end;
|
|
|
|
procedure TThdCollectWindowInfo.Execute;
|
|
begin
|
|
|
|
end;
|
|
|
|
end.
|