I am developing a Swing application in Java. The program is to be run on dedicated Windows 7 Touch Screen machines, and as far as I know, this program should be the only thing running on them under normal operation.
I've noticed that Windows 7's touch screen interface has this thing where it will hold back mousedown events. Due to the "tap-and-hold right click" gesture, Windows 7 won't actually send the application a mouse down event until:
the user "touch ups" (raise their finger from a touch, at which point both down and up are sent)
moves their finger (at which point the click becomes a drag)
or the right click circle gesture times out (after about 5-6 seconds)
Trivially, this means that buttons don't look depressed on the application until the mouse down event is sent (and never draw depressed at all with a quick tap). But, recently, more seriously, this means functionality that requires a press-and-hold cannot happen without major amounts of confusion to the average user.
At this point in development it is far too late to turn around and start from scratch with one of the many touch libraries offered on other questions. (They require redoing the entire application in their component hierarchy, and that simply isn't feasible. Plus things coded to use mouse events would then have to be recoded using touch events, and we don't really need multi-touch...)
Yes, I have attempted to simply turn off the touch-and-hold right click gesture. Unfortunately, doing so simply disables the drawing of a circle indicating a right click gesture around your finger and the fire of the subsequent right click. It does NOT remove the underlying problem: the delayed mouse down event for up to six seconds.
My Question: Is there a way to:
Ideally, indicate to Windows that my application is a touch-ready application, so it sends down events immediately (but, I suppose, still send mouse events instead of touch events)? I can see that the built-in soft keyboard works correctly, it seems. I just want my Java application to do the same.
Disable the delay entirely on the computer, but still provide basic touch functionality?
Potentially something as simple as this question, which seems to be asking about the same phenomenon, but in Java?
Typically this type of behavior is controlled by the touch device driver installed on the device. All of the touch manufacturers I have seen have control panel apps that allow you to customize touch behavior. So for instance you can tell the driver to send a mouse click immediately up receipt of a touch rather than delaying briefly in order to prevent an incidental touch from initiating an input event.
Related
I have an application written in Java, but I am also using the JNI to execute C++ written by myself. I would now like to generate mouse and key press events programmatically. For reasons, events from the "real mouse" interfere with those that are generated. Is there a way to completely block any mouse and key events being sent to that application/window?
The program is running on Ubuntu 20 and hence it uses the X Window system.
Edit: A solution which intercepts mouse/keyboard events on a very low-level and simply ignores them is equally appreciated. I simply don't want them to reach the windows created from Java code.
So recently my phone was stolen and besides all the trouble I had with the lost files I was pretty angry about the fact that it didn't came to my mind to create an app for android that prevents easy stealing or to be precise that will act as a Trojan horse inside of the thief's pocket. So what i thought about is an application that kicks in whenever you're holding your standby button or whatever you usually do to shutdown your phone. This application then looks like the real shutdown menu and asks you to shutdown with a pin or without one and whenever you shutdown without the right pin the phone will actually fake shut down in a way where it is still transmitting GPS and connecting to the next transmission tower so it is easily locatable (by fake shutdown I mean a black screen and silent mode until you are repeating the same method you used to shut your phone down). So is there any way of creating an app that has a higher priority than the android shutdown system so a custom menu pops up whenever you're trying to shutdown your phone?
Your idea isn't entirely impossible for Android.
There is no way for an app to have a higher priority than the Android Shutdown menu. However, that doesn't mean there's no hope.
If you remember popular Alarm apps, they typically have a feature that prevent you from turning off your phone when the alarm rings. This is usually done by detecting that a Long Press of the Power Button is pressed and then dismissing the Power Off Menu.
You can look at this answer for how to do this: https://stackoverflow.com/a/53679477
However, this is just so you can dismiss Android's Power Off Menu so you can show your own Power-Off Menu.
Afterwards, with your idea of displaying a Black Screen and Silent Mode... there's actually four three problems.
Screen Backlight for non AMOLED screens
Status and Navigation Bars
Can't block a Forced Shutdown
Personally, during the early days of Android and my early years of Android development, I released an app with a similar idea (have the phone give off the illusion of being turned off, so there's a higher possibility of phone remaining on if stolen), but due to those four problematic areas, the app has been retired.
So I speak with experience in saying that:
A black screen doesn't play nicely with screens that require a backlight. Even at lowest brightness settings, a completely black screen will still easily be seen as on.
Android doesn't have a way permanently hide the Navigation and Status bars. The best you'll get is Immersive Mode, but this mode will cause the bars to temporarily appear if you touch the screen. Even if you use a Full-Screen Activity, swiping down or swiping up will still show these bars. I believe your only option for hiding both of these bars is Root.
There's absolutely no way to block someone from doing a force shutdown. This completely bypasses the Power Off Menu and it's simply unblockable. So while your app might block some thieves, it might not block the more paranoid ones.
Hopefully, my answer is enough to nudge you in the right direction for your app.
I am using Java to create an foreground application that uses the Robot class to send mouse clicks to other applications real-time.
Here's my issue at the moment: my application needs to read from a device in real time and keep sending Robot commands. However, mouse clicks cause the focus to be shifted to other applications. Therefore, I cannot continue reading or sending commands.
I've tried jDialog's and jFrame's setAutoRequestFocus(false) and true but I couldn't keep the window's focus.
Can anyone help me with this?
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.
I'm learning about AI and (just for fun and practice, not profit or anything evil) I'd like to write a little bot to play a rinky-dink Flash game for me.
As a Microsoft hater, I'm embarrassed to say that I know and have used the required function calls some time ago under Windows, programming in Delphi. But these days I try to do everything under Linux and I don't seem to have any idea.
Requirements:
to grab part of the screen's contents in image or bitmap form, periodically or on programmatic request;
to simulate mouse pointer moves and left clicks under programmatic control;
keyboard grabbing might come in handy too.
Ideally, I'd like to do this from a Clojure application running in the JVM, so a Java compatible library would be the cat's meow. But failing that, I could write myself a C program to mediate between X Window and my app via local TCP/IP.
You can always rely upon the good old java.awt.Robot class, which, i think, has all the features you're asking :
moving mouse
capturing a Rectangle on screen
clicking mouse