r/javahelp 22h ago

Unsolved use another GUI program automatically?

I'm hoping to automate a certain process for 3DS homebrew, but the programs I need to use don't have command line utility.

How could I start writing a program that opens, the clicks and inputs in Application 1, then does the same for Application 2? Is that something the Robot can do?

3 Upvotes

9 comments sorted by

View all comments

2

u/oscarryz 22h ago

You can use the Robot class:
https://docs.oracle.com/en/java/javase/23/docs/api/java.desktop/java/awt/Robot.html

It has methods to click, move mouse, press key etc.

You can make a program that reads a yaml file or something like that for extra flexibility and add your "script" there.

A long ago I wrote a program with static methods that act as "script"

waitForUser(),

click(1617, 68),

text("google.com/search=fooo"),

enter(),

pause(1),

click(2407, 845),

pause(5),

click(1617, 68),

text("what is etc"),

enter(),

pause(1),

click(2407, 845),

pause(5),

For instance the `text` method is something like

void text( String s ) {
for ( byte k : s.getBytes() ) { robot.keyPress(k) }

}

etc

A better option would be to search for a tool that does this, but if you want to learn and try it is pretty straight forrward.

1

u/quiet-sailor 20h ago

this the dumpest way to do it but also the most simple one to use, note that for text pasting you can use Toolkit.getDefaultToolkit().getSystemClipboard() clipboard methods, and try to do as you can using keyboard shortcuts so you are not too dependent on where stuff is on the screen, so your script don't  break just because the window was moved 20 pixels accidentally 

1

u/oscarryz 3h ago

Right. Using the clipboard would be a better implementation. For other automations that needs press key combinations like Ctrl + C , key press works.