mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-24 10:12:20 -05:00
Simba: TProc, TProcArr, SetTarget, and GetProcesses.
This commit is contained in:
parent
40c93dc127
commit
58faccf182
@ -284,3 +284,13 @@ begin
|
|||||||
mDebugLn('Exception in GetClipBoard: ' + e.message);
|
mDebugLn('Exception in GetClipBoard: ' + e.message);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ps_GetProcesses: TProcArr;
|
||||||
|
begin
|
||||||
|
Result := CurrThread.Client.IOManager.GetProcesses;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ps_SetTarget(Proc: TProc);
|
||||||
|
begin
|
||||||
|
CurrThread.Client.IOManager.SetTargetEx(Proc);
|
||||||
|
end;
|
||||||
|
@ -64,3 +64,6 @@ AddTypeS('TSP_Property','(SP_WriteTimeStamp,SP_OnTerminate)');
|
|||||||
AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0
|
AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0
|
||||||
AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1
|
AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1
|
||||||
AddConstantN('mouse_Middle','integer').SetInt(ps_mouse_middle);//2
|
AddConstantN('mouse_Middle','integer').SetInt(ps_mouse_middle);//2
|
||||||
|
|
||||||
|
AddTypes('TProc', 'record Title: string; Handle: integer; Pid: integer; Width, Height: integer; end;');
|
||||||
|
AddTypes('TProcArr', 'array of TProc;');
|
||||||
|
@ -195,6 +195,8 @@ AddFunction(@ps_messageBox,'function MessageBox(Text, Caption: string; Flags: Lo
|
|||||||
AddFunction(@ps_MessageDlg,'function MessageDlg(const Caption, Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons) : integer;');
|
AddFunction(@ps_MessageDlg,'function MessageDlg(const Caption, Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons) : integer;');
|
||||||
AddFunction(@ps_SetClipBoard, 'procedure SetClipBoard(const Data: string);');
|
AddFunction(@ps_SetClipBoard, 'procedure SetClipBoard(const Data: string);');
|
||||||
AddFunction(@ps_GetClipBoard, 'function GetClipBoard: string;');
|
AddFunction(@ps_GetClipBoard, 'function GetClipBoard: string;');
|
||||||
|
AddFunction(@ps_GetProcesses, 'function GetProcesses: TProcArr;');
|
||||||
|
AddFunction(@ps_SetTarget, 'procedure SetTarget(Proc: TProc);');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{string}
|
{string}
|
||||||
|
@ -317,6 +317,8 @@ interface
|
|||||||
procedure FreeTarget(idx: integer);
|
procedure FreeTarget(idx: integer);
|
||||||
procedure SetState(val: Boolean);
|
procedure SetState(val: Boolean);
|
||||||
|
|
||||||
|
function GetProcesses: TProcArr; virtual; abstract;
|
||||||
|
procedure SetTargetEx(Proc: TProc); virtual; abstract;
|
||||||
protected
|
protected
|
||||||
function SetImageTarget(target: TTarget): integer;
|
function SetImageTarget(target: TTarget): integer;
|
||||||
function SetKeyMouseTarget(target: TTarget): integer;
|
function SetKeyMouseTarget(target: TTarget): integer;
|
||||||
|
@ -106,6 +106,14 @@ type
|
|||||||
x1, y1, x2, y2: Integer;
|
x1, y1, x2, y2: Integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TProc = record
|
||||||
|
Title: string;
|
||||||
|
Handle: integer;
|
||||||
|
Pid: integer;
|
||||||
|
Width, Height: integer;
|
||||||
|
end;
|
||||||
|
TProcArr = array of TProc;
|
||||||
|
|
||||||
const
|
const
|
||||||
TMDTMPointSize = 5*SizeOf(integer)+Sizeof(boolean);
|
TMDTMPointSize = 5*SizeOf(integer)+Sizeof(boolean);
|
||||||
type
|
type
|
||||||
|
@ -96,6 +96,9 @@ interface
|
|||||||
constructor Create(plugin_dir: string);
|
constructor Create(plugin_dir: string);
|
||||||
function SetTarget(target: TNativeWindow): integer; overload;
|
function SetTarget(target: TNativeWindow): integer; overload;
|
||||||
procedure SetDesktop; override;
|
procedure SetDesktop; override;
|
||||||
|
|
||||||
|
function GetProcesses: TProcArr; override;
|
||||||
|
procedure SetTargetEx(Proc: TProc); overload;
|
||||||
private
|
private
|
||||||
procedure NativeInit; override;
|
procedure NativeInit; override;
|
||||||
procedure NativeFree; override;
|
procedure NativeFree; override;
|
||||||
@ -510,4 +513,14 @@ implementation
|
|||||||
SetBothTargets(TWindow.Create(display, screennum, target))
|
SetBothTargets(TWindow.Create(display, screennum, target))
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TIOManager.GetProcesses: TProcArr;
|
||||||
|
begin
|
||||||
|
raise Exception.Create('GetProcesses: Not Implemented.');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager.SetTargetEx(Proc: TProc);
|
||||||
|
begin
|
||||||
|
raise Exception.Create('SetTargetEx: Not Implemented.');
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -27,7 +27,7 @@ unit os_windows;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, mufasatypes, windows, graphics, LCLType, bitmaps, IOManager, WinKeyInput;
|
Classes, SysUtils, mufasatypes, windows, graphics, LCLType, LCLIntf, bitmaps, IOManager, WinKeyInput;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -97,6 +97,8 @@ interface
|
|||||||
constructor Create(plugin_dir: string);
|
constructor Create(plugin_dir: string);
|
||||||
function SetTarget(target: TNativeWindow): integer; overload;
|
function SetTarget(target: TNativeWindow): integer; overload;
|
||||||
procedure SetDesktop; override;
|
procedure SetDesktop; override;
|
||||||
|
function GetProcesses: TProcArr; override;
|
||||||
|
procedure SetTargetEx(Proc: TProc); overload;
|
||||||
protected
|
protected
|
||||||
DesktopHWND : Hwnd;
|
DesktopHWND : Hwnd;
|
||||||
procedure NativeInit; override;
|
procedure NativeInit; override;
|
||||||
@ -441,6 +443,41 @@ end;
|
|||||||
SetBothTargets(TWindow.Create(target));
|
SetBothTargets(TWindow.Create(target));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
threadvar
|
||||||
|
ProcArr: TProcArr;
|
||||||
|
|
||||||
|
function EnumProcess(Handle: HWND; Param: LPARAM): WINBOOL; stdcall;
|
||||||
|
var
|
||||||
|
Proc: TProc;
|
||||||
|
I: integer;
|
||||||
|
pPid: DWORD;
|
||||||
|
begin
|
||||||
|
Result := (not ((Handle = 0) or (Handle = null)));
|
||||||
|
if ((Result) and (IsWindowVisible(Handle))) then
|
||||||
|
begin
|
||||||
|
I := Length(ProcArr);
|
||||||
|
SetLength(ProcArr, I + 1);
|
||||||
|
ProcArr[I].Handle := Handle;
|
||||||
|
SetLength(ProcArr[I].Title, 255);
|
||||||
|
SetLength(ProcArr[I].Title, GetWindowText(Handle, PChar(ProcArr[I].Title), Length(ProcArr[I].Title)));
|
||||||
|
GetWindowSize(Handle, ProcArr[I].Width, ProcArr[I].Height);
|
||||||
|
GetWindowThreadProcessId(Handle, pPid);
|
||||||
|
ProcArr[I].Pid := pPid;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIOManager.GetProcesses: TProcArr;
|
||||||
|
begin
|
||||||
|
SetLength(ProcArr, 0);
|
||||||
|
EnumWindows(@EnumProcess, 0);
|
||||||
|
Result := ProcArr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager.SetTargetEx(Proc: TProc);
|
||||||
|
begin
|
||||||
|
SetTarget(Proc.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TDesktopWindow }
|
{ TDesktopWindow }
|
||||||
|
|
||||||
constructor TDesktopWindow.Create(DesktopHandle: HWND);
|
constructor TDesktopWindow.Create(DesktopHandle: HWND);
|
||||||
@ -450,9 +487,6 @@ begin
|
|||||||
self.handle:= DesktopHandle;
|
self.handle:= DesktopHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TDesktopWindow.WindowRect(out Rect : TRect) : Boolean;
|
function TDesktopWindow.WindowRect(out Rect : TRect) : Boolean;
|
||||||
begin
|
begin
|
||||||
Rect.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN);
|
Rect.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
|
Loading…
Reference in New Issue
Block a user