I'm making a program which for myself personally, would be very useful and remove one of the many things that annoy me. :p To sum it up, I'm making a java application to register a global keyboard+mousemotion listener, and when a certain key on the keyboard is pushed it opens a program. What my java program would do, is before it goes directly to the program to open it, the java program will intercept the call and say 'open on the screen that contains the cursor'. And then will continue to launch the program, but make it open on screen 1,2,3,4 etc.
What my question is, how can I make for example google chrome open on screen 1,2,3,4 etc. Is it possible with java?
Thanks
You can use the java Runtime class. Here is an example Maybe you can tell your operating system which screen you want via terminal. (In linux DISPLAY env variable.)
Related
I want to build a program that does the following:
User clicks on a button (like on a GUI) to record his/hers movements.
Then, the user does a set of actions on the computer - this could be clicking on file explorer and deleting/creating/renaming a file, opening Chrome or another program etc... basically a few keyboard/mouse movements.
Then the user can specify a time at which the program should replicate this recording of movements. (The program hasn't been stopped and it uses the current time of the computer's clock to know when to do it)
Can I do something like this in Java? Searched quite a bit and couldn't see something relevant. The only thing that came to my mind since I am still a beginner is MouseEvents etc but I don't think these can be done outside the frames of GUI.
Thanks in advance I am keen to build this project!
JNativeHook is worth looking into for this and similar purposes. I found it helpful.
https://github.com/kwhat/jnativehook
On the Mac where I do my programming, I have an app installed called BetterTouchTool that allows me to bind keyboard shortcuts to 'gestures' on my trackpad. I have bound a gesture (that doesn't have an Apple default) to the shortcut command+Q, which quits the active program. I have found this very convenient for quickly quitting programs that I am testing, so that I can get back to writing code.
However for the graphical game that I am programming, this action makes it so that I can't use a three finger swipe to switch between windows (several other gestures are also disabled). This will also happen if I go up to the menu and click quit or if I click the red x close button. The fix is to either restart my computer or (and this is really weird) to click the in-game close button which calls System.exit(0);. I know that most players will be using this but I still want to figure out why this is happening. In addition games like Minecraft on my computer don't do this.
I am using a JFrame with setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); in the code. In an attempt to fix the issue I have tried registering a com.apple.eawt.QuitHandler that calls System.exit(0); in the handler.
I have no idea what would be considered relevant code here, so whatever you would like to see, just let me know.
I figured it out. There was one rouge Thread.sleep() call in my JFrame that was somehow effecting my system.
This would be my first post ever on stackoverflow.com
I have found many many of the answers to my questions but this one question i cannot figure out.
I know that it is possible to invoke few android commands via either java code or other html code and was wondering if it is possible for a my website to set an image on my site as their wallpaper on their android phone.
To better explain this is what im doing.
My website will have say for example 50 images of something and when the user clicks on one of those photos the website will ( if possible ) invoke the android " set as background " Process.
Currently it is set to just download to their phone and then the user goes and selects the photo as their wallpaper from their download folder on their phone.
Thank You in advance
Vick S.
Interesting question. In Android, java runtime environment is what being run inside OS, and in order to execute commands you wish to make, rooting to OS is only way, and this can be done in java. So, if I were in your shoes, I'd drop the idea of rooting command line to android via HTML - but look over onto java side.
In other words...yes, it is possible. But, end-users will already have their phone/mobile pre-set to guard against that rooting commands, but to ask for permission from owner. If owner clicked yes, then you are in game. The hardest part about this is the complexity requiring bunches of efforts to code such rooting functions.
But, this could something as a starting point, at least? Running Shell commands though java code on Android?
Good luck!
First of all, im not looking for a bot, that's clicking on the screen so i can't use my computer.
I'm curios on how to interact with flash games without having to use awt.robot to click the screen.
Is this possible in Java, and how can i do it.
I prefer java, as that's what im best at, but if c# has some huge advantages im willing to use that :)
First of all, im not looking for a bot, that's clicking on the screen
so i can't use my computer.
You're mistaken if you think using AWT Robot clicking on the "screen" means you can't use your computer.
One way to do what you want by actually using Java's Robot would simply be to run another graphical display and have your bot act on that graphical display.
There are a lot of ways to do that. A virtual machine would be one. Spawning a second X server would be another (under Un*x most likely). Configuring Windows so that it can accept several graphical logins at once and opening a "remote desktop" session, etc.
There are actually bots abusing Flash games and one way to do it is precisely by doing what I just described ; )
I am currently developing a Java cross-platform (windows and mac os x) application running in background and displaying a pop-up window on some user's or system's events like "Copy and Paste" or programs' launching.
Nevertheless, I would like to detect first, if any other program, not necessarily developed in Java, is running in full screen mode. In that case, I would not display my window.
For instance, when user is watching a movie in full screen (media player...), a Powerpoint presentation...
So here are my questions :
1. Is there any way to do such a thing in Java language?
2. If it's not possible, I will do my "full screen mode detector" in another language but it has to be able to communicate with my Java app to notify the presence of a full screen window.
3. If it's not possible (1) : do you know the best language to do it? I found other solutions in C# or C++ MFC( How to check if an other program is running in fullscreen mode, eg. a media player ).
Any idea would be very useful.
Thanks a lot.
Sebastian
Eventually I did one external program for each OS which checks if active window is in full screen mode or not and writes the result on standard output. My Java app calls the good program according to the OS and read the result.
I used :
C# for Windows
Carbon for Mac OS X
The hardest part was Mac OS X version.
Don't hesitate to ask me if you're interested in these programs.
Thanks again for your help!
You can capture screen with java.awt.Robot, can you implement algorithm based on screenshot?
The simplest solution is to give the user the option of enabling/disabling your pop-ups. That way they can pick and choose when to receive pop ups.