PDA

View Full Version : PInput - Interact with any OSRS client without taking over I/O units



Patriq
09-22-2018, 10:30 PM
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 (https://villavu.com/forum/showthread.php?t=118176) (read more about his post (https://villavu.com/forum/showthread.php?t=118176) 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:

Download the latest KInput.dll and PInput.dll from here (https://github.com/Patriq/KInput/releases)
Download the latest source code from here (https://github.com/Patriq/PInput/releases)


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:

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!):

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:

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:

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

Kasi
09-22-2018, 11:13 PM
First! GZ on release.

acow
09-23-2018, 12:37 AM
Looks pretty neat, ty Patriq and Kasi.

tls
09-23-2018, 02:31 AM
Instead of overriding all of the simba functions you should just add TEIOS support to kinput.

Patriq
09-25-2018, 01:10 AM
Doing that as we speak :D

AlwaysConfused
11-22-2018, 12:14 AM
Thanks very much, this helped me so much. ATM, i have a script to start SMART, a script to grab the PID from the target window, and a script which logs in and bots. Very very basic code, but it works. If anyone would like me to share this/or help me make this three scripts in one, then let me know thanks.

Zombified
11-26-2018, 08:52 AM
Very nice work!

Is it possible for this to work on certain RSPS jar executable files?

felparers
04-30-2019, 04:02 PM
Very nice work!

Is it possible for this to work on certain RSPS jar executable files?

If anyone is wondering, the answer is in the first line of the post: a plugin which allows you to interact with any OSRS game client

imalama101
06-05-2019, 06:12 PM
If anyone is wondering, the answer is in the first line of the post: a plugin which allows you to interact with any OSRS game client

Like runelite? So it wont work with jar then any way to modify it to work for rsps?

Also any way to make this work with linux? Will wine make it work for linux?

rsbotter123
08-25-2019, 07:41 PM
Looks cool will try this soon thanks.

Mr Moan
09-10-2019, 08:59 AM
To anyone wondering who may come across this in the future.

I was having issues with this and two pieces of information i want to share that I learned from the Patriq the developer(thanks boss you're the man)
the first bullet was critical to solving my problem, the second is more along the lines of trivia.


1. THE RUNESAPE CLIENT MUST BE 32bit!!! a 64bit client WILL NOT WORK
2. while pinput isn't "just for OSRS" it still has restrictions (beyond working only on windows which is already mentioned) namely
"It [the window targeted by pinput] needs to be a jre window with a canvas in it[.] So it won't work for notepad for example"

LordJashin
09-10-2019, 01:31 PM
I'm really surprised how far the community has gone to help people that aren't using S.M.A.R.T.
Bravo.

elephant
04-14-2020, 05:10 PM
Does anyone know if this still works, or something needs to be fixed? I'm having issues getting it working can't get it to send input to any windows for some reason.

Pntbllfrk
04-17-2020, 02:44 PM
Does anyone know if this still works, or something needs to be fixed? I'm having issues getting it working can't get it to send input to any windows for some reason.

Java 8, 32bit v111 is the only version that works for me.

kakadudl
04-18-2020, 12:17 PM
Java 8, 32bit v111 is the only version that works for me.

Hey, since these forums are dead mostly and I saw you posted this yesterday... I'm wondering if you've tried multiboxing with that plugin and if yes, is there a way to get info (like search for DTM/colors) from the multi clients without them being active?

Pntbllfrk
04-16-2021, 07:51 PM
What would I need to change in @Kasi's source to use on another java application?