r/javahelp • • Dec 26 '19

Would it be possible to write a java program that can clone all mouse and keyboard inputs on one window to another background window?

Let's just say I'm on one window doing stuff with my keyboard and mouse, I want the program to basically clone everything I've done and send these simulated events to a background window.

16 Upvotes

11 comments sorted by

1

u/turunambartanen Dec 26 '19

If you write both Windows yourself in e.g. Java that's relatively easy. If not I have no idea how it would be done.

2

u/NiteBiker6969 Dec 26 '19

Can you clarify what you mean by writing both windows

2

u/wildjokers Dec 26 '19

They mean if you write the application that is both sending and receiving the cloned events.

1

u/turunambartanen Dec 26 '19

Do you want to make other windows (half) transparent to clicks, like your browser, Skype, file explorer...? Or do you want to write an application that contains two windows (e.g. With the swing library in Java)?

1

u/[deleted] Dec 27 '19

It sounds like you're trying to hack someone rather than creating something with code.

Please don't.

If that's not the case, the use case seems odd enough, what are you trying to do?

1

u/NiteBiker6969 Dec 27 '19

To clear the confusion. Im writing a program to ultimately allow me to multibox in league. Thats why I wanted to forst write a program to control two different chrome windows at the same time.

1

u/[deleted] Dec 27 '19

Macro or bot maybe

2

u/irocgts Dec 26 '19 edited Dec 26 '19

Yeah it's possible. If these windows are exactly the same.

You'd have to use some windows dlls. I think it's called JNI. You'll be able to click the same buttons and enter text in the same text boxes and whatnot. There is a few DLLs that mimic mouse and keyboard commands to specific windows and elements in windows.

I am being vague because I don't have all the info. I am on my phone in Panama.

1

u/turunambartanen Dec 26 '19

1

u/irocgts Dec 26 '19

Thanks, fixed it. I am in my phone on vacation.

1

u/7Point1 Extreme Brewer Dec 27 '19

I cannot help you in regards to actual production but I can shed some light on a similar program I found last night:

IOGraphica is a cute little program that records mouse movements and spits out a piece of art a few hours later. This is achieved via MousePath which is open source, developed using java, and can be downloaded from here. I had a 2s look at the source code and MousePath seems to be built with a language/library/IDE called Processing which is developed using the class called "PApplet.java".

On the other hand if you're looking for a program to simply do a repetitive task what about something in the same vein as AutoHotKey (AHK)?

Maybe not exactly what you're looking for, but hope these lead you somewhere.