1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 16:55:01 -05:00

Merge branch 'GetProcSetTar' of https://github.com/Dgby714/Simba into Dgby714-GetProcSetTar

This commit is contained in:
Merlijn Wajer 2010-12-24 00:56:52 +01:00
commit 4f861ffb5d
7 changed files with 82 additions and 9 deletions

View File

@ -284,3 +284,13 @@ begin
mDebugLn('Exception in GetClipBoard: ' + e.message);
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;

View File

@ -64,3 +64,6 @@ AddTypeS('TSP_Property','(SP_WriteTimeStamp,SP_OnTerminate)');
AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0
AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1
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;');

View File

@ -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_SetClipBoard, 'procedure SetClipBoard(const Data: string);');
AddFunction(@ps_GetClipBoard, 'function GetClipBoard: string;');
AddFunction(@ps_GetProcesses, 'function GetProcesses: TSysProcArr;');
AddFunction(@ps_SetTarget, 'procedure SetTarget(Proc: TSysProc);');
{$ENDIF}
{string}

View File

@ -317,6 +317,8 @@ interface
procedure FreeTarget(idx: integer);
procedure SetState(val: Boolean);
function GetProcesses: TSysProcArr; virtual; abstract;
procedure SetTargetEx(Proc: TSysProc); virtual; abstract;
protected
function SetImageTarget(target: TTarget): integer;
function SetKeyMouseTarget(target: TTarget): integer;

View File

@ -106,6 +106,14 @@ type
x1, y1, x2, y2: Integer;
end;
TSysProc = record
Title: string;
Handle: integer;
Pid: integer;
Width, Height: integer;
end;
TSysProcArr = array of TSysProc;
const
TMDTMPointSize = 5*SizeOf(integer)+Sizeof(boolean);
type

View File

@ -96,6 +96,9 @@ interface
constructor Create(plugin_dir: string);
function SetTarget(target: TNativeWindow): integer; overload;
procedure SetDesktop; override;
function GetProcesses: TSysProcArr; override;
procedure SetTargetEx(Proc: TSysProc); overload;
private
procedure NativeInit; override;
procedure NativeFree; override;
@ -510,4 +513,14 @@ implementation
SetBothTargets(TWindow.Create(display, screennum, target))
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.

View File

@ -27,7 +27,7 @@ unit os_windows;
interface
uses
Classes, SysUtils, mufasatypes, windows, graphics, LCLType, bitmaps, IOManager, WinKeyInput;
Classes, SysUtils, mufasatypes, windows, graphics, LCLType, LCLIntf, bitmaps, IOManager, WinKeyInput;
type
@ -97,6 +97,9 @@ interface
constructor Create(plugin_dir: string);
function SetTarget(target: TNativeWindow): integer; overload;
procedure SetDesktop; override;
function GetProcesses: TSysProcArr; override;
procedure SetTargetEx(Proc: TSysProc); overload;
protected
DesktopHWND : Hwnd;
procedure NativeInit; override;
@ -441,6 +444,41 @@ end;
SetBothTargets(TWindow.Create(target));
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 }
constructor TDesktopWindow.Create(DesktopHandle: HWND);
@ -450,9 +488,6 @@ begin
self.handle:= DesktopHandle;
end;
function TDesktopWindow.WindowRect(out Rect : TRect) : Boolean;
begin
Rect.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN);