I have a java Robot program ,where it can type a word on notepad,word etc,.
But the problem is i am not getting focus of window application, when i tried to enter the cursor in its textbox manually by using ALT-TAB,
And the application is not available in the list ,while doing ALT-TAB ,
also it is not visible in Task Manager-> Application tab
but, it is available with Processes tab of Task Manager.
Is there any solution to get focus of that windows application for keyPress using Java Robot.
Also ,in some other PC's ,i am getting Clear Focus of the application when i put the cursor manually after running the java robot program. I have installed JDK1.6 in all my PC's. It is not working only in my PC's.
Thanks in advance!!
I think that your best bet is to use JNA to allow you to make system calls.
Assuming a Windows program, you could use JNA to make calls to the user32.dll including dll functions such as FindWindowEx(...) and SetForegroundWindow(...) to set the window of your choice to the foreground.
Instead of getting the focus of the other app, you could put your robot to the background, returning whatever was in the foreground previously (ie your target app) to get the focus.
Related
I have an application in java in which I have start and stop buttons in swing. I want to make a windows service which automatically clicks on start button. Is it possible and if it's possible how to do it?
You must find a way to identify the main window of your swing application from the Windows service (common usage is the title bar)
Then, you search in subwindows how to identify the Start button (generally the id, but you could use text)
All that must be done only once, using the Windows SDK tools and/or you knowing from the GUI application
Now the service :
searches the top-level windows for the right one
searches the relevant button
gets it position
uses SendInput API function to simulate a MOUSEEVENTF_LEFTDOWN and MOUSEEVENTF_LEFTUP event over the button
The last part could be done in Java (with Robot), but the others will need to use Windows API
My application is a GUI frontend for a database, and is built using Java's Swing library. The application is compiled using Java 5 (1.5).
When the application is ran using Java 7 I am able to write in textfields, comboboxes, etc. using the keyboard, until the data is loaded from the database then the cursor continues to blink but what I type is not typed on the screen. However, if I click on another windows e.g. my browser and then come back to my application, or minimize and maximize my application, the keyboard input works and behaves as normal.
When I run with Java 1.5 or 1.6, however this issue does not appear.Any insight on what might have changed in Java 1.7, and possibly a workaround?
PS: So far I made a workaround as follows:
frame.setFocusableWindowState(false);
frame.setFocusableWindowState(true);
However, I have this inside a timer, as I don't know where exactly the issue occurs. This is not really a proper solution...
Thanks
Is there any option which i can use to Control Window State of another App. from a Java Application .
Like if i need to minimize or maximize another app. window on Ubuntu Enviroment (if it's matter's im using Gnome Window Manager).
Bests
Two bad options:
1) use java.awt.Robot to click the appropriate coordinates where the window is. (You have to hard code these)
2) use jni
Is it possible to get image contents of an obstructed window without bringing it to the front? Also, is it possible to send mouse clicks to a specific locations of such window? I want to do this in Java, using JNA, running Windows XP (if it is possible, would it also work on Windows 7?). If that can be done, would you mind telling me what functions will be needed and where can I read about it, because I have never worked with JNA yet. Thank you.
I'm trying to find a concrete yes for some assumptions I have about developing a Java Swing app to be run on a Windows tablet device (I believe it'll be running Windows XP). We have a demo we are writing and we're leveraging previous experience with Java Swing to write the UI and I just want to make sure that touch events in Windows are treated like mouse clicks, is this true? Does anyone have any direct experience writing Swing apps for Windows tablets? The target device is http://www.amazon.com/Promotion-X70EX-3GP-Accessory-Standard/dp/B002MZZX76.
Also, wondering if the soft keyboard will automatically be activated when focus is given to a JTextField and other Swing data entry fields.
Thanks!
We developed an application in Swing which runs well on Windows XP tablets. Yes, touches are treated just like mouse clicks. However, I can only confirm this for basic touch events, e.g. clicking on a button. I can neither confirm nor deny whether they work for more complex gestures.
As for the soft keyboard, I cannot remember whether this works or not. In the end our users ended up using the tablet just like a regular laptop, i.e. with the keyboard not the touch screen. This is mostly due to the amount of text they need to enter in the application.