mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 01:02:17 -05:00
Made smart work again, and make the mouse move outside target (on windows).
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@429 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
d6014fe316
commit
5995ac8bde
@ -42,7 +42,7 @@ uses
|
|||||||
ColorBox, about, framefunctionlist, ocr, updateform, simbasettings;
|
ColorBox, about, framefunctionlist, ocr, updateform, simbasettings;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 427;
|
SimbaVersion = 429;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -531,6 +531,7 @@ begin
|
|||||||
ScriptThread := TMMLPSThread.Create(True,@CurrentSyncInfo);
|
ScriptThread := TMMLPSThread.Create(True,@CurrentSyncInfo);
|
||||||
{$IFNDEF TERMINALWRITELN}
|
{$IFNDEF TERMINALWRITELN}
|
||||||
ScriptThread.SetDebug(@formWriteln);
|
ScriptThread.SetDebug(@formWriteln);
|
||||||
|
ScriptThread.DebugMemo := Self.Memo1;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ScriptThread.SetPSScript(CurrScript.SynEdit.Lines.Text);
|
ScriptThread.SetPSScript(CurrScript.SynEdit.Lines.Text);
|
||||||
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
||||||
|
@ -1,6 +1,54 @@
|
|||||||
program new;
|
program new;
|
||||||
|
|
||||||
{.LoadDLL libsmart}
|
{.LoadDLL libsmart}
|
||||||
|
function IsKeyDown(C:Char): Boolean;
|
||||||
|
begin
|
||||||
|
Result := SmartIsKeyDown(ord(c));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MoveMouse(x, y: Integer);
|
||||||
|
begin
|
||||||
|
SmartMoveMouse(x, y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure HoldMouse(x, y: Integer; left: Boolean);
|
||||||
|
begin
|
||||||
|
SmartHoldMouse(x, y, left);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ReleaseMouse(x, y: Integer; left: Boolean);
|
||||||
|
begin
|
||||||
|
SmartReleaseMouse(x, y, left);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure KeyUp(key: Byte);
|
||||||
|
begin
|
||||||
|
If Key = 13 Then
|
||||||
|
Key := 10;
|
||||||
|
SmartReleaseKey(key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure KeyDown(key: Byte);
|
||||||
|
begin
|
||||||
|
If Key = 13 Then
|
||||||
|
Key := 10;
|
||||||
|
SmartHoldKey(key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SendKeys(S: String);
|
||||||
|
begin
|
||||||
|
SmartSendKeys(S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure GetMousePos(var x, y: Integer);
|
||||||
|
begin
|
||||||
|
SmartGetMousePos(x, y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetColor(x, y: Integer): Integer;
|
||||||
|
begin
|
||||||
|
result:= SmartGetColor(x, y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
w,h:integer;
|
w,h:integer;
|
||||||
|
@ -42,6 +42,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
procedure ClearDebug;
|
||||||
|
begin
|
||||||
|
if Assigned(CurrThread.DebugMemo) then
|
||||||
|
CurrThread.Synchronize(@CurrThread.DebugMemo.Clear);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure SaveScreenshot(FileName: string);
|
procedure SaveScreenshot(FileName: string);
|
||||||
var
|
var
|
||||||
w,h : integer;
|
w,h : integer;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
|
AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
|
||||||
AddFunction(nil,'procedure writeln(x);'); //We use special function for this
|
AddFunction(nil,'procedure Writeln(x);'); //We use special function for this
|
||||||
|
|
||||||
{ DTM }
|
{ DTM }
|
||||||
SetCurrSection('DTM');
|
SetCurrSection('DTM');
|
||||||
@ -41,6 +41,7 @@ AddFunction(@ps_addpDTM, 'function AddpDTM(d: pDTM): Integer;');
|
|||||||
|
|
||||||
{maths}
|
{maths}
|
||||||
SetCurrSection('Math');
|
SetCurrSection('Math');
|
||||||
|
AddFunction(nil,'function Round(e:extended) : integer');
|
||||||
AddFunction(@ceil,'function ceil(e : extended) : integer');
|
AddFunction(@ceil,'function ceil(e : extended) : integer');
|
||||||
AddFunction(@power,'function pow(base,exponent : extended) : extended');
|
AddFunction(@power,'function pow(base,exponent : extended) : extended');
|
||||||
AddFunction(@max,'function Max(a, b: Integer): Integer;');
|
AddFunction(@max,'function Max(a, b: Integer): Integer;');
|
||||||
@ -92,6 +93,7 @@ AddFunction(@DrawBitmapDebugImg,'procedure DrawBitmapDebugImg(bmp: integer);');
|
|||||||
AddFunction(@GetDebugBitmap,'function GetDebugBitmap: integer;');
|
AddFunction(@GetDebugBitmap,'function GetDebugBitmap: integer;');
|
||||||
AddFunction(@Random,'function Random(Int: integer): integer;');
|
AddFunction(@Random,'function Random(Int: integer): integer;');
|
||||||
AddFunction(@NewThreadCall,'function NewThreadCall(procname : string) : cardinal');
|
AddFunction(@NewThreadCall,'function NewThreadCall(procname : string) : cardinal');
|
||||||
|
AddFunction(@ClearDebug,'procedure ClearDebug;');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ type
|
|||||||
PSScript : TPSScript; // Moved to public, as we can't kill it otherwise.
|
PSScript : TPSScript; // Moved to public, as we can't kill it otherwise.
|
||||||
Client : TClient;
|
Client : TClient;
|
||||||
StartTime : LongWord;
|
StartTime : LongWord;
|
||||||
|
DebugMemo : TMemo;
|
||||||
SyncInfo : PSyncInfo; //We need this for callthreadsafe
|
SyncInfo : PSyncInfo; //We need this for callthreadsafe
|
||||||
ErrorData : PErrorData; //We need this for thread-safety etc
|
ErrorData : PErrorData; //We need this for thread-safety etc
|
||||||
property OnError : TOnError read FOnError write FOnError;
|
property OnError : TOnError read FOnError write FOnError;
|
||||||
|
@ -282,17 +282,22 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
w,h: integer;
|
w,h: integer;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
GetWindowRect(Window.TargetHandle, Rect);
|
||||||
|
x := x + rect.left;
|
||||||
|
y := y + rect.top;
|
||||||
|
if (x<0) or (y<0) then
|
||||||
|
writeln('Negative coords, what now?');
|
||||||
|
Windows.SetCursorPos(x, y);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF LINUX}
|
||||||
// This may be a bit too much overhead.
|
// This may be a bit too much overhead.
|
||||||
Window.GetDimensions(w, h);
|
Window.GetDimensions(w, h);
|
||||||
if (x < 0) or (y < 0) or (x > w) or (y > h) then
|
if (x < 0) or (y < 0) or (x > w) or (y > h) then
|
||||||
raise Exception.CreateFmt('SetMousePos: X, Y (%d, %d) is not valid', [x, y]);
|
raise Exception.CreateFmt('SetMousePos: X, Y (%d, %d) is not valid', [x, y]);
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
GetWindowRect(Window.TargetHandle, Rect);
|
|
||||||
Windows.SetCursorPos(x + Rect.Left, y + Rect.Top);
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
|
||||||
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
|
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
|
||||||
XWarpPointer(Window.XDisplay, 0, Window.CurWindow, 0, 0, 0, 0, X, Y);
|
XWarpPointer(Window.XDisplay, 0, Window.CurWindow, 0, 0, 0, 0, X, Y);
|
||||||
XFlush(Window.XDisplay);
|
XFlush(Window.XDisplay);
|
||||||
|
@ -719,8 +719,8 @@ function TMWindow.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload;
|
|||||||
begin
|
begin
|
||||||
if Self.Frozen then
|
if Self.Frozen then
|
||||||
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
||||||
OnSetTarget(w_ArrayPtr,self.TargetMode);
|
|
||||||
Self.SetDesktop;//Set the underlaying window to desktop for key-sending etc..
|
Self.SetDesktop;//Set the underlaying window to desktop for key-sending etc..
|
||||||
|
OnSetTarget(w_ArrayPtr,self.TargetMode);
|
||||||
Self.ArrayPtr := ArrPtr;
|
Self.ArrayPtr := ArrPtr;
|
||||||
Self.ArraySize := Size;
|
Self.ArraySize := Size;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user