mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-28 20:12:16 -05:00
Merge branch 'GetProcSetTar' of https://github.com/Dgby714/Simba into Dgby714-GetProcSetTar
This commit is contained in:
commit
4f861ffb5d
@ -284,3 +284,13 @@ begin
|
|||||||
mDebugLn('Exception in GetClipBoard: ' + e.message);
|
mDebugLn('Exception in GetClipBoard: ' + e.message);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ps_GetProcesses: TSysProcArr;
|
||||||
|
begin
|
||||||
|
Result := CurrThread.Client.IOManager.GetProcesses;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ps_SetTarget(Proc: TSysProc);
|
||||||
|
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('TSysProc', 'record Title: string; Handle: integer; Pid: integer; Width, Height: integer; end;');
|
||||||
|
AddTypes('TSysProcArr', 'array of TSysProc;');
|
||||||
|
@ -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: TSysProcArr;');
|
||||||
|
AddFunction(@ps_SetTarget, 'procedure SetTarget(Proc: TSysProc);');
|
||||||
{$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: TSysProcArr; virtual; abstract;
|
||||||
|
procedure SetTargetEx(Proc: TSysProc); 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;
|
||||||
|
|
||||||
|
TSysProc = record
|
||||||
|
Title: string;
|
||||||
|
Handle: integer;
|
||||||
|
Pid: integer;
|
||||||
|
Width, Height: integer;
|
||||||
|
end;
|
||||||
|
TSysProcArr = array of TSysProc;
|
||||||
|
|
||||||
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: TSysProcArr; override;
|
||||||
|
procedure SetTargetEx(Proc: TSysProc); 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: TSysProcArr;
|
||||||
|
begin
|
||||||
|
raise Exception.Create('GetProcesses: Not Implemented.');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager.SetTargetEx(Proc: TSysProc);
|
||||||
|
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
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ interface
|
|||||||
keyinput: TKeyInput;
|
keyinput: TKeyInput;
|
||||||
procedure ValidateBuffer(w,h:integer);
|
procedure ValidateBuffer(w,h:integer);
|
||||||
protected
|
protected
|
||||||
function WindowRect(out Rect : TRect) : Boolean;virtual;
|
function WindowRect(out Rect : TRect) : Boolean; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDesktopWindow }
|
{ TDesktopWindow }
|
||||||
@ -97,6 +97,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: TSysProcArr; override;
|
||||||
|
procedure SetTargetEx(Proc: TSysProc); overload;
|
||||||
protected
|
protected
|
||||||
DesktopHWND : Hwnd;
|
DesktopHWND : Hwnd;
|
||||||
procedure NativeInit; override;
|
procedure NativeInit; override;
|
||||||
@ -424,7 +427,7 @@ end;
|
|||||||
|
|
||||||
procedure TIOManager.NativeInit;
|
procedure TIOManager.NativeInit;
|
||||||
begin
|
begin
|
||||||
self.DesktopHWND:= GetDesktopWindow;
|
self.DesktopHWND:= GetDesktopWindow;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIOManager.NativeFree;
|
procedure TIOManager.NativeFree;
|
||||||
@ -441,6 +444,41 @@ end;
|
|||||||
SetBothTargets(TWindow.Create(target));
|
SetBothTargets(TWindow.Create(target));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
threadvar
|
||||||
|
ProcArr: TSysProcArr;
|
||||||
|
|
||||||
|
function EnumProcess(Handle: HWND; Param: LPARAM): WINBOOL; stdcall;
|
||||||
|
var
|
||||||
|
Proc: TSysProc;
|
||||||
|
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: TSysProcArr;
|
||||||
|
begin
|
||||||
|
SetLength(ProcArr, 0);
|
||||||
|
EnumWindows(@EnumProcess, 0);
|
||||||
|
Result := ProcArr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager.SetTargetEx(Proc: TSysProc);
|
||||||
|
begin
|
||||||
|
SetTarget(Proc.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TDesktopWindow }
|
{ TDesktopWindow }
|
||||||
|
|
||||||
constructor TDesktopWindow.Create(DesktopHandle: HWND);
|
constructor TDesktopWindow.Create(DesktopHandle: HWND);
|
||||||
@ -450,9 +488,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