How can I click on this button by using Java Robot Class? Or maybe there is any better way to do that? This button is from external Windows program, and the button is from QT5 library as i know so I guess I must just simulate a mouse to click that if i want make it run right? I tried to find that pixel by pixel but its still so hard to me, Im sure i saw somewhere solution to do that but cant find it from few hours...
You'll most likely need to use the JNI.
https://en.wikipedia.org/wiki/Java_Native_Interface
Related
I want to be able to take a screenshot of a portion or all of the screen using Java. The generally accepted method of doing this to use the Robot class, but that doesn't work in this case. I have multiple transparent JavaFX stages on the screen, and any screenshot taken with the Robot class seems to treat them as completely opaque.
I have also tried having the program simulate the presses of Ctrl+PrtSc. I can't seem to get it to actually put the screenshot into the clipboard before the method finishes though, even if I attempt to have it wait until there is a picture in the clipboard.
Is there any more direct way of getting a screenshot? Anything specific to Swing/AWT, unfortunately, will not work.
I am working on eclipse RCP product. I want to know how to add hints to users. I mean when they open our tool for the first time, I want to add some hints to click here and there (kind of a walk-through of the tool). Not just light bulb hint (which we see in eclipse), some other different types of arrows as well. My requirement can be best illustrated with the interactive tutorial of criminal case game in facebook. Please check this image with hints: http://www.mobygames.com/images/shots/l/673844-criminal-case-browser-screenshot-first-crime-scene-a-tutorial.jpg. When the user accesses the game for the first time, they have a very nice walk through. Can this be done in eclipse? May be not this much fancier, but at least basic version with an arrow to indicate user to click the button, and then the next button, and so on. Please let me know if any of you have idea on this. It would be of great help. Please point me to any example if it is available online.
You could try to use popup to achieve this. Each hint is an SWT popup and place it in the right location.
So I am working on an app using android studio, and in the XML file, I realized if you edit the android:BackgroundTint of a button, you can change the color or the button, however, I wanted to change this within my java code, and I cannot figure out how to do this. The reason I dont just simply change android:BackgroundColor is that that changes the overall shape and effect of the button, and I do not want to sacrifice this. Any help to solve this is greatly appreciated.
Figured it out. This is the code I was looking for:
button.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);
Using Java, is it possible to detect user actions, such as key-presses, mouse-button-presses, and/or mouse's screen location, without the use of GUI elements?
If it is, how could I implement it?
Otherwise, what are the alternatives?
The only StackOverflow source i found on this matter is this question, which is unanswered.
And the only sources I found outside StackOverflow on this matter point to an "Invisible GUI" solution, wish is something i really want to avoid.
It can be implemented using JNI and/or JNA but this cannot be really called "java implementation" because you will have to write platform specific native code.
Alternative solution I tried is to use full screen transparent widow that is listening to all events of mouse and keyboard and "forwards" them to the real application using class Robot. I tried this approach. It works well with one limitation: there is a problem to support "mouse over" events of applications: the mouse is not moving over the real application. It is moving over the transparent java window.
Use the java.awt.event.KeyListener class. You will have to write three methods in which you can write which key you want to be detected, and whatever you want to have happen when the key is pressed.
Recently I made an autoclicker for a game, which would allow you to use F1 and F2 to turn it on or off, once I finished the application I thought to myself, "oh great, I forgot Java doesn't let you record outside keystrokes and mouse movements", is there any simple non-native ways to do this?
Thanks.
Nope. You can do application wide keyboard and mouse handling, but you have very few options if your application is not the foreground application. The best you can do is discover the mouse location:
java.awt.MouseInfo.getPointerInfo().getLocation()
This will always work. You are out of luck for keyboard input though. For that you will need to write native code.