From: Flight
This is what I dug up on Freddy's site, but again this is code for Scar so as far as it goes to make it Simba-compatible, I dunno.
program Silent;
function PostMessage(Wnd: HWND; Msg: Cardinal; LParam, WParam: Integer): LongBool; external 'PostMessageW@user32.dll stdcall';
function SendMessage(Wnd: HWND; Msg: Cardinal; LParam, WParam: Integer): LongBool; external 'SendMessageW@user32.dll stdcall';
const
WM_KEYDOWN = 256;
WM_KEYUP = 257;
WM_MOUSEMOVE = 512;
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;
WM_RBUTTONDOWN = 516;
WM_RBUTTONUP = 517;
MK_LBUTTON = 1;
MK_RBUTTON = 2;
function MakeLong(A, B: Word): LongInt;
begin
Result := Integer(A) or Integer(B) shl 16;
end;
procedure _Silent_KeyDown(const Target: HWND; const Key: Byte);
begin
if (Target > 0) then
PostMessage(Target, WM_KEYDOWN, Key, 0);
end;
procedure _Silent_KeyUp(const Target: HWND; const Key: Byte);
begin
if (Target > 0) then
PostMessage(Target, WM_KEYUP, Key, 0);
end;
procedure _Silent_MoveMouse(const Target: HWND; const x, y:Integer);
begin
if (Target > 0) then
SendMessage(Target, WM_MOUSEMOVE, 0, MakeLong(x, y));
end;
procedure _Silent_HoldMouse(const Target: HWND; const x, y: Integer; const Left: Boolean);
begin
if (Target > 0) then
if Left then
SendMessage(Target, WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(x, y))
else
SendMessage(Target, WM_RBUTTONDOWN, MK_RBUTTON, MakeLong(x, y));
end;
procedure _Silent_ReleaseMouse(const Target: HWND; const x, y: Integer; const Left: Boolean);
begin
if (Target > 0) then
if Left then
SendMessage(Target, WM_LBUTTONUP, 0, MakeLong(x, y))
else
SendMessage(Target, WM_RBUTTONUP, 0, MakeLong(x, y));
end;
procedure Silent_KeyDown(const Key: Byte);
begin
_Silent_KeyDown(GetClientWindowHandle, Key);
end;
procedure Silent_KeyUp(const Key: Byte);
begin
_Silent_KeyUp(GetClientWindowHandle, Key);
end;
procedure Silent_MoveMouse(const x, y: Integer);
begin
_Silent_MoveMouse(GetClientWindowHandle, x, y);
end;
procedure Silent_HoldMouse(const x, y: Integer; const Left: Boolean);
begin
_Silent_HoldMouse(GetClientWindowHandle, x, y, Left);
end;
procedure Silent_ReleaseMouse(const x, y: Integer; const Left: Boolean);
begin
_Silent_ReleaseMouse(GetClientWindowHandle, x, y, Left);
end;
var
i, ii: Integer;
begin
for i := 50 to 150 do
for ii := 50 to 150 do
if ((i mod 10) = 0) or ((ii mod 10) = 0) then
begin
Silent_HoldMouse(i, ii, True);
Silent_ReleaseMouse(i, ii, True);
end;
end.
Maybe someone can find this useful in converting to Simba? I played around with it myself but to no avail.
Go to settings -> settings -> interpreter -> allowsyscalls and set it to true..
Now: select a window.. You'll see an ID appear in the debug, copy and paste this into the script (for the window constant) and you will see it works.
program Silent;
const window = 4130762;
function PostMessage(Wnd: HWND; Msg: Cardinal; LParam, WParam: Integer): LongBool; external 'PostMessageW@user32.dll stdcall';
function SendMessage(Wnd: HWND; Msg: Cardinal; LParam, WParam: Integer): LongBool; external 'SendMessageW@user32.dll stdcall';
const
WM_KEYDOWN = 256;
WM_KEYUP = 257;
WM_MOUSEMOVE = 512;
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;
WM_RBUTTONDOWN = 516;
WM_RBUTTONUP = 517;
MK_LBUTTON = 1;
MK_RBUTTON = 2;
function MakeLong(A, B: Word): LongInt;
begin
Result := Integer(A) or Integer(B) shl 16;
end;
procedure _Silent_KeyDown(const Target: HWND; const Key: Byte);
begin
if (Target > 0) then
PostMessage(Target, WM_KEYDOWN, Key, 0);
end;
procedure _Silent_KeyUp(const Target: HWND; const Key: Byte);
begin
if (Target > 0) then
PostMessage(Target, WM_KEYUP, Key, 0);
end;
procedure _Silent_MoveMouse(const Target: HWND; const x, y:Integer);
begin
if (Target > 0) then
SendMessage(Target, WM_MOUSEMOVE, 0, MakeLong(x, y));
end;
procedure _Silent_HoldMouse(const Target: HWND; const x, y: Integer; const Left: Boolean);
begin
if (Target > 0) then
if Left then
SendMessage(Target, WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(x, y))
else
SendMessage(Target, WM_RBUTTONDOWN, MK_RBUTTON, MakeLong(x, y));
end;
procedure _Silent_ReleaseMouse(const Target: HWND; const x, y: Integer; const Left: Boolean);
begin
if (Target > 0) then
if Left then
SendMessage(Target, WM_LBUTTONUP, 0, MakeLong(x, y))
else
SendMessage(Target, WM_RBUTTONUP, 0, MakeLong(x, y));
end;
procedure Silent_KeyDown(const Key: Byte);
begin
_Silent_KeyDown(window, Key);
end;
procedure Silent_KeyUp(const Key: Byte);
begin
_Silent_KeyUp(window, Key);
end;
procedure Silent_MoveMouse(const x, y: Integer);
begin
_Silent_MoveMouse(window, x, y);
end;
procedure Silent_HoldMouse(const x, y: Integer; const Left: Boolean);
begin
_Silent_HoldMouse(window, x, y, Left);
end;
procedure Silent_ReleaseMouse(const x, y: Integer; const Left: Boolean);
begin
_Silent_ReleaseMouse(window, x, y, Left);
end;
var
i, ii: Integer;
begin
Silent_HoldMouse(5,5,false);
Silent_ReleaseMouse(5,5,false);{
for i := 50 to 150 do
for ii := 50 to 150 do
if ((i mod 10) = 0) or ((ii mod 10) = 0) then
begin
Silent_HoldMouse(i, ii, True);
Silent_ReleaseMouse(i, ii, True);
end; }
end.