I have an application written on Java running on the machine (Linux/Windows). I want to make this application run like a background application so that it does not interrupt while using other applications in the system. Now I want to popup a screen and show some buttons (to do some tasks based on the selection) when a QR Code is scanned using a scanned attached to the USB port. When this scanning happens my Java application that initiates the popup screen is running in the system tray.
--Edit--
I have used key listeners to identify the bar code scanning and pull out information from database based on what is scanned. But while scanning my application, was open. So I attached the action listeners in the AWT level so that the key strokes/scanning is caught and taken care off. But now in the current case I wont be having any windows active. SO I NEED TO CAPTURE THE SCANNED INPUT INTERNALLY WHEN THE APPLICATION IS MINIMIZED IN THE SYSTEM TRAY.
I think the only avenue open to you is capturing system-wide keyboard events. There is a library that handles that for Java: jnativehook. But how you're going to detect which events are coming specifically from your HID device, I'm not sure.
There is also the JavaHIDAPI, an amateur-level project whose "hello, world" test example failed with IOException on my machine. The good part is, all the code is there, including the native C for Windows.
Finally, I found this, a very good tutorial on how to talk to HID's on Windows.
You can see if Headless Mode works or start up VNC on your host.
Related
I'm trying to build a report-building tool (which has a UI written in JavaFX) that has the following features:
When the system (re-)boots, it should auto-start in the background (without showing the UI)
It should have an icon in the system tray
The UI should only show when the user clicks on the system tray icon
A report should be generated either once a day/week/month, at a specific time, automatically
It should "snooze/sleep" in the interim period and use minimal resources while it awaits the next trigger time
It should show a toast pop-up / Windows notification / whatever when a new report has been generated
(The bold ones are the real problems, the italics are maybe solvable--given some resources I found--and the un-formatted one I have a work-around for, namely to place it on in the Startup folder in the AppData folder of the users' machine.)
But the clincher is the following: due to my company's policies, I'm NOT allowed to build register it as a Windows service. Also, converting it into a web service, placing it on a server, and using Control-M (or a cron expression) are also off the table. (That's a long story for another day.) I'm not sure how to implement it and I've been stuck on this for a bit.
I've taken a look at Quartz, this other StackOverflow question, and some other resources on how to run the Java app in the background, but most resources tell me to add it as a Windows service and I keep hitting a brick wall. Also, I don't know how much of an effect the application would have on the users' machines if I ran the application in the background with the solutions mentioned in the other StackOverflow answer. I need to have a minimal processing footprint in the interim period.
I'm also unsure of how to package the application as an EXE. For now, I'm going to turn it into an executable JAR. (Any help on this would also be welcome.)
I'm open to any suggestions and ideas and even other resources to look at for further reading. Anything to help me out here is welcome.
I am developing a windows based java application, One of the requirements for this application is, when this application is installed on other machines, it should open automatically at specified time and user has to select some option on the application, If the user didn't choose the options and close/minimize the application, the application should pop-up again after some time.
Please let me know how do I achieve the above functionality.
First of all, because of security reasons windows services are prevented from interaction with users via Gui - one should make significant efforts to show window from service process. You described process that unlikely may be called windows service, rather it should be scheduled. Some kind of Windows port of cron will help you. For instance, nnCron. It can in particular display, hide, close, kill, minimize, maximize and hide specified windows to system tray. Just in case, to fully answer your question - turning process (that has no GUI and was not created as service) into windows service is easy with help of srvany. Srvany.exe allows any Windows application to run as a service.
I realise that there are other questions on this topic, all of which I have attempted to implement the answers of and failed. I would like to end up with a full blown answer, ideally with a demonstration, on how to, in Windows and only Windows set the desktop background instantly without having the user log in and out or lock and log back in. The approach that involves using the runtime console to push the registry entries about and then rundll32 user32.dll call UpdatePerUserSystemPreferences has yet to work for me. The desired behaviour is achieved when the user right clicks an image file in explorer and selects 'Set as desktop background'. I'd like to do that programatically even if it devolves to the level of opening a hidden explorer window and right-clicking a file in it as long as the user sees nothing of it. The application in question updates the user's desktop background image with useful system information. The image to be used will be generated and regenerated every five seconds.
Can I change my Windows desktop wallpaper programmatically in Java/Groovy?
So the correct way is with JNA if you are not familiar with JNA or if you haven't used JNA the link above is for you. Otherwise you are right about using natives but you never stated how you are using them so I am just taking shots in the dark here.
My main aim is to count the number of mouse clicks on a particular application.
Imagine I have opened Microsoft Word and a web browser on my PC. My Java code should tell me how many times I clicked on Word and on the web browser. I need the application name and the number of clicks.
How can I do this? Any solution must work for MAC, Linux and Windows.
You could try a library such as jnativehook: http://code.google.com/p/jnativehook/. Check out their examples on this page.
This library uses native functionality to provide access to mouse events that would otherwise be impossible to achieve in pure Java. It appears to support Mac, Linux and Windows.
I found this SO link to get the currently opened applications in task bar.
In addition I need to get the applications running in system tray using Java.
Also suggest me if there is some other good ways to find the opened apps in task bar.
How to find in which application the mouse click and key stroke has been ocuured?
I also want to track the mouse click by viewing which application is opened by the particular mouse click.
I want this application to run both in Linux and windows environment. I need to do all the above in one of my application using Java.