PInput
Pinput is both an include and a plugin which allows you to interact with any OSRS game client without the need of having it focused, nor taking over your I/O units.
It uses @Kasi's KInput to achieve this (read more about his post if you want to know how it works and how to compile it).
The plugin offers a high level interface to KInput, so you can do basic things like moving/pressing the mouse and using the keyboard more easily without having to know what events and in which order you need to send them into the client.
The include is just a wrapper around the plugin with the following features:
- Automatic PID discovery using target window (thanks @slacky)
- Multi-boxing (send the same action to mwith the ability to index certain clients when needed)
- Override Simba's Mouse and Keyboard functions, so you can use this in any script by adding a few amount of lines to it.
Sounds great, but how do I start using it?
How to set it up:
Things needed:
After downloading everything:
- Drag KInput.dll and PInput.dll to the Plugins folder in Simba (for me C:\Simba\Plugins)
- Extract the source code to the Includes folder in Simba (for me C:\Simba\Includes)
- Rename the extracted folder to PInput
How to use it:
I think is better to show a few examples rather than trying to explain what you need to do
Basic setup:
Simba Code:
program new;
{$include PInput/PInput.simba}
procedure Stop();
begin
PInput.Shutdown(); // Make sure you shutdown PInput
end;
var
X, Y: Integer;
begin
PInput.Setup(78952); // Setup PInput for client with PID 78952
PInput.OverrideSimba := false; // Don't override Simba Mouse and Keyboard functions
PInput.MoveMouse(580, 230);
PInput.HoldMouse(580, 230, mouse_Left);
PInput.MoveMouse(700, 400);
sleep(10);
PInput.ReleaseMouse(700, 400, mouse_Left);
PInput.SendKeys('hey', 30, 30);
PInput.PressKey(13);
PInput.SendKeys('hey', 30, 30);
PInput.GetMousePos(X, Y);
WriteLn(X, ' ', Y);
Stop();
end.
Basic setup with a single client with automatic PID discovery (Make sure you target a window!):
Simba Code:
program new;
{$include PInput/PInput.simba}
procedure Stop();
begin
PInput.Shutdown(); // Make sure you shutdown PInput
end;
begin
PInput.Setup(); // Setup PInput. Grabs the PID of the target window.
PInput.OverrideSimba := false; // Don't override Simba Mouse and Keyboard functions
PInput.MoveMouse(580, 230);
PInput.HoldMouse(580, 230, mouse_Left);
PInput.MoveMouse(700, 400);
sleep(10);
Stop();
end.
As you may have guessed, if you do:
Simba Code:
PInput.OverrideSimba := true;
PInput will override Simba's Mouse and Keyboard functions. (Only works when using one client, is enabled by default when only one client is used.)
Basic multi-box:
Simba Code:
program new;
{$include PInput/PInput.simba}
procedure Stop();
begin
PInput.Shutdown(); // Make sure you shutdown PInput
end;
var
X, Y: Integer;
begin
PInput.Setup([78952, 78951, 78953]); // Setup PInput for clients with PID 78952, 78951, 78953
PInput.MoveMouse(580, 230); // Makes all clients move their mouses
PInput.HoldMouse(0, 580, 230, mouse_Left); // Makes the first client hold his mouse
PInput.MoveMouse(0, 700, 400); // Makes the first client move his mouse
sleep(10);
PInput.ReleaseMouse(0, 700, 400, mouse_Left); // Makes the first client release his mouse
PInput.SendKeys(1, 'hey', 30, 30); // Makes the second client send 'hey'
PInput.PressKey(1, 13); // Makes the second client press enter
PInput.GetMousePos(X, Y); // Gets the mouse of all clients (the first client)
WriteLn(X, ' ', Y);
Stop();
end.
Notes:
- Only works with Windows because it uses Windows API
I hope you all enjoy using this project as much as I enjoyed creating it! Learned a bunch, and got more familiar with both Windows API and JNI thanks to @Kasi and his KInput plugin.
This release has been verified working 22th September 2018