Reputation: 7644
I'm currently working on a project for my studies. I'm trying to solve a simple puzzle game by using breadth first search. After I have found the optimal solution I want to simulate a series of keypresses (using awt.Robot) to solve the game.
Is there a way to bring a window with known title to the foreground. I'm using Linux and it would be okay to simply use some CLI tools since this is not the main focus of my project.
Upvotes: 1
Views: 1208
Reputation: 7644
I found a tool called wmctrl which does excatly this. I simply start it using ProcessBuilder.
new ProcessBuilder("wmctrl", "-a", title).start()
Upvotes: 1
Reputation: 52337
To answer part of your question, see xprop
or xwininfo
to find the window.
For the second part, while Xlib provides a function to do this (XRaiseWindow()
), I don't know how to do from the command line or inside Java. See this thread though.
Upvotes: 0