I have to display x,y coordinate values on mouse pointer tooltip. The text should follow the mouse pointer. How can this be done.
From an rcp application, I will click a button, then application will be minimized. Then wherever (on desktop/other application) I move the mouse pointer, it should display some text attached to mouse. I know how to find the coordinates of mouse pointer location, but I want to display those values in mouse pointer tool tip.
Any thoughts.
Unfortunately, what you are asking can't be done in SWT. The only way to do this, and communicate/control it through a Java/Eclipse/SWT app, would be through the Java Native Interface (JNI). You could write a native program (in C++, for example, for a specific OS) to monitor the cursor and change its image as it moves across the screen. You can also pipe data from that native program to your java app. But that is a whole 'nother world beyond Java.
SWT can only manage the cursor over a specific SWT control. Not outside of a SWT control, on the desktop or over another app's windows.
Now, if you could settle for having, say a small dialog/window open (via your application), perhaps tucked in the corner of the screen (rather than at the mouse cursor), that shows the current mouse position that could be done. You'd have to have a process/thread running in the background that would monitor the current screen mouse position, via:
display.getCursorLocation();
Basically the runnable in the process/thread would simply be in an infinite loop and reading the cursor location, then updating the x,y coords in the "output box."
As an extension to this, you could have a small, bare-bones SWT shell that "follows" the cursor around during the cursor read in the thread. You would simply update the location of the shell based on the current cursor location, and set text in that window (a nested Text control) to the appropriate coordinates. Of course, I don't know how "clean" that would appear, as I haven't tried it. But that's about the best you can do in SWT without JNI.
But in these methods you wouldn't be changing the actual cursor/image.
Hope that helps.
Related
I want to make a program that recognize a button that is in the League of Legends client, and when the queue's button shows up the mouse instantly click on it.
Its a sort of a AutoAccept Client...
There is already a program that someone did, but it has so many unnecessary things and it does not work very well....
How do I do to recognize a element inside a program to make my mouse move there when it shows up?
I can try to code this in any language, just gimme a tip pls
You can create a program that takes a screenshot every 100ms, use a recognition algorithm of your choice and then (optionally) performs a mouse click. There are enough libraries that can screenshot for you, you should be able to recognise the button by colour and location and every language should have some method of controlling the mouse.
Sikulix (can be paired with python) is a perfect tool to use for this. It scans over your screen constantly, and if the image in question pops up (the accept button) you can click on it.
You will have to take a screenshot and likely store it as .png so the program knows what it is looking for.
Google Sikulix.
I'm fluent in java, and have messed with vb.net, but I prefer java. I wish to make a program that ++'s a variable everytime I click my mouse in a certain coordinate on my screen. Not sure how to record when a mouse click has happened outside of the program's forms.
This can't be done in pure Java but people have written JNI libraries that can capture global mouse and keyboard events. Take a look at
https://github.com/kwhat/jnativehook
I would like to know how can I create a mouse move after pressing a button?
I am a fish in coding starting with a simple project and would love to create a step by step clicking process where the mouse will be scrolling and pointing in a certain point, img, or maybe to a class of my project?
Currently, there is no way to force a mouse movement via Javascript mainly due to its security implications.
In your case, you can use focus to guide the user to the specific portion of the page that you want.
You cannot move the mouse in JavaScript for the moment. What you can do however is scrolling the page so that a elements goes under the mouse cursor.
My idea is to move the element you want with JavaScript under the mouse cursor. When the user clicks your button, you can, in the event handler capture the mouse coordinates and use those to place any element exactly under the mouse cursor.
The result of the mouse cursor is above this element can be achieved that way.
try to Create COM, then client will ask to accept some installation.
see here ; http://febru.soluvas.com/2015/02/javascript-move-mouse.html
In java you can use the Robot Class to move the mouse and fire mouse clicks. While this is cool, it also "hijacks" the users mouse, so you cannot multitask.
What I want to do is make a "Fake" mouse that acts independently of the system's mouse cursor, and lives only inside my java applet. In this sense the applet would think it was being clicked by the mouse in various (x,y) positions (within the applet), however I can do whatever I want with the system mouse and it will not be affected.
I have seen programs that have accomplished this, I just have no idea where to begin. Perhaps I am just using the wrong terminology for this functionality.
Any suggestions on where to look would be much appreciated. -Thanks
What I want to do is make a "Fake" mouse that acts independently of the system's mouse cursor, and lives only inside my java applet.
Create a Runnable FakeMouse class that fires mouse clicks. Tony Depace provided the code, which I'm adding to the answer to help others.
MouseEvent aClick = new MouseEvent(this, MouseEvent.MOUSE_CLICKED,
System.currentTimeMillis(), 0, 10, 10, 1, false);
dispatchEvent(aClick);
Run the FakeMouse class in a thread in your Java applet.
I want to write a program which can control my cursor movements depending on the the way I move my finger on the touchpad. I want my program to get the location where the user touched the touchpad, then I want to control mouse movement using my own program. I want do this in Java. Can I do this in Java? I would like to run it on Windows OS. Does my laptops touchpad device driver provide some API by which I can get the info about when and where the user touched the touchpad?
Think about this situation.
Person wants to exit your program. They touch the trackpad. Your program moves the cursor somewhere they didn't expect. They're upset and confused.
They continue to touch the trackpad, your program continues to do something they didn't expect. They find they're unable to control the cursor. Now what?
Generally, having your program move the cursor is a recipe for disaster.
The cursor is hard enough to spot on the screen. X-windows applications which do "cursor warping" to dialog boxes have an option to disable this because it is confusing.
Removing control of the cursor from the user makes the computer (already very hard to use) much harder to use because there's this "mode" thing. When your program is running, one thing happens. When your program is not running, something different happens.
Look at http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Cursor.html
There do not appear to be any methods to change the cursor's position. It tracks the mouse.
However, look at http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html
This has the ability to synthesize mouse events. Feel free to play with it.