I'm working with an application where one of the options which I have to develop is to change Windows 10 cursor size. In my case it its important to change cursor size for the whole windows, not only for a specific java application window. Currently I'm able to change size of specific cursor type by modifying Windows registry attributes under HKEY_CURRENT_USER → Control Panel → Cursors directory.
Unfortunately, I need to set cursor size bigger than 32x32px.
Somewhere I've found a solution where there was a possibility to cover existing mouse cursor by a bitmap and just follow the position of a cursor, but I don't know how to start with the implementation.
I searched on the Internet and I've found some applications that allow user to modify size of cursor for whole Windows 10—for example, this was CursorFX.
Do you know how to increase cursor size programmatically?
You can set any size cursor you want using the SetSystemCursor API. You are not limited to the SM_CXCURSOR/SM_CYCURSOR metrics (cf. GetSystemMetrics function)—those just tell you the system's default cursor size, which is typically 32×32 (or 48×48 on high-DPI systems). I know for a fact that this works as far back as Windows XP; I'm pretty sure it works further back than that.
The key lies in how you load the cursor resource. As you probably already know, you need an HCURSOR object to pass to SetSystemCursor. This is a handle-to-cursor, in Windows API speak. The obvious way to load a cursor is by calling the LoadCursor API function, but that is a very old function, introduced with 16-bit Windows and it is limited to loading cursors of size SM_CXCURSOR×SM_CYCURSOR. So you don't want that†; you want to call LoadImage, which as the documentation indicates is the modern replacement function. It takes an enumerated integer parameter indicating which type of image to load: IMAGE_BITMAP (0), IMAGE_ICON (1), IMAGE_CURSOR (2), or IMAGE_ENHMETAFILE (3). Obviously, IMAGE_CURSOR is what you want to use here.
You can either load from a cursor resource embedded into your application's binary (as a Win32 resource), or you can load from a *.CUR/*.ANI file from the disk. To do the latter, pass the LR_LOADFROMFILE flag to the LoadImage function.
I don't know Java, so I can't translate this to Java with whatever syntax is required there to make native Windows API calls, but here is the code in C:
// Load from a CUR file, at C:\LargeCursor.cur, with a size of 64x64 pixels
HCURSOR hCursor = (HCURSOR)LoadImage(NULL,
"C:\\LargeCursor.cur"),
IMAGE_CURSOR,
64, 64,
LR_DEFAULTCOLOR | LR_LOADFROMFILE);
assert(hCursor != NULL); // verify that load was successful
BOOL result = SetSystemCursor(hCursor, OCR_NORMAL);
assert(result != FALSE); // verify that the change was successful
// Load from an embedded resource, IDC_CURSOR, with a size of 64x64 pixels
HCURSOR hCursor = (HCURSOR)LoadImage(GetModuleHandle(NULL),
IDC_CURSOR),
IMAGE_CURSOR,
64, 64,
LR_DEFAULTCOLOR);
assert(hCursor != NULL); // verify that load was successful
BOOL result = SetSystemCursor(hCursor, OCR_NORMAL);
assert(result != FALSE); // verify that the change was successful
Note that the SetSystemCursor requires one of the OCR_* constants to identify which system cursor type to change. These aren't included by default when you include Windows.h; you have to define OEMRESOURCE before including Windows.h. I'm assuming, though, that with Java, you're just defining the constants yourself as enumerated values. In that case, they're all available in the MSDN documentation for SetSystemCursor. For example, OCR_NORMAL is 32512.
Notice, though, that what we're doing here is loading a new cursor (i.e., image) of the desired size, and then setting that. That works fine. What you can't easily do is just expand the size of the existing cursor glyph. To do that, you'd have to retrieve the current cursor glyph, draw it onto a bitmap, scale that bitmap to the desired size, convert that bitmap to an HCURSOR, and then set that HCURSOR using SetSystemCursor. And, naturally, the problem with that is Windows cursor glyphs are just bitmaps, so they're not infinitely scalable. You will start losing resolution quickly, so this is not recommended. If you need a large-size cursor, you will need to provide your own image.
By "CursorFX", I believe you're thinking of AniFX (by the same fellow, Attila Kovrig, who wrote IcoFX). This is a cursor image editor and would be a great way to create the *.CUR/*.ANI file(s) you need. But you could just as easily use some other piece of software designed for creating cursors; there are myriad to choose from.
__
† Not that you wanted that function with SetSystemCursor anyway, since SetSystemCursor destroys the specified cursor by calling DestroyCursor. You would need to do LoadCursor and then CopyCursor before calling SetSystemCursor. This is all spelled out in the documentation for SetSystemCursor, but as I said, you don't need to worry about this anymore because you just use LoadImage (without the LR_SHARED flag).
I have some screencasts that explain how to perform a task in a specific software. My objective is to detect where the user clicks on a button or menu item or anything else that leads to a change. One solution to this work is to detect the mouse cursor's location. There are several challenges:
The cursor's icon changes and is not always the same in all videos (e.g. Mac vs Win, arrow shaped and hand shaped cursors).
I tried template matching, but I did not get good results because the display settings of each person who is capturing the video may be different and therefore the size of the cursor will be different.
Calculating the difference between two consequent images can give the mouse cursors only in the output but I need to have only the second or the last image's cursor's location in the output not both of them.
I also tried to find an object tracking sample solution, but they are either for live videos or for multiple objects ( I only need to spot the mouse cursor or the locations where the mouse was clicked on)
I would appreciate if if anyone could suggest a solution, ready to use code (in Java/Matlab/Python), software or API for this work.
I trying to find a method in java which could tell me when the mouse cursor has entered the borders of a folder or file component. Can anybody refer me to a good document or help me on this?
Mouse events happen within the context of the Java application (not your desktop). I don't think this is possible.
The best you can do is check if the cursor has left your Java application. As user BackSlash mentioned,
you can use PointerInfo to get the pointer coordinates, but you cannot
know if it has entered something that isn't part of your java
application.
http://docs.oracle.com/javase/7/docs/api/java/awt/PointerInfo.html
An alternative option is:
Add an AWTEventListener for focus events. As long as your app has
focus before the button is clicked you'll receive a focus lost event.
Then query for the pointer position.
The limitation is that, of course, your app loses focus. So depending
on what you are ultimately trying to achieve this might not be useful.
Source: https://stackoverflow.com/a/2420208/2498729
The company I work for has an java application that runs on esmertec jbed JVM on windows mobile 6.
There is a requirement to capture a user's signature as part of some new functionality. One option is to try and implement this in java. This has been tried previously and has been found to be a bit slow.
I think the better option would be to get a native component to handle the drawing of the signature and save it to file. Does anyone know of a component that I would be able to use?
Creating our own component is an option as well but if there is one available already, I would prefer to use that.
For completeness, I'll answer my own question.
I could not find an existing component that done this. We ended up writing some c++ code that would handle this.
The code would get a handle to the Java canvas and register our own callback function with it. This callback function would record any mouse movement within the canvas and draw a line when necessary (either on mouse up or after a number of points had been drawn). Once the user leaves the screen we would save the canvas to file and re-register the original canvas callback function.
I need to make kind of a game in Java but I am a total beginner. It has to be applicable to the web and I need to use images on it and action listeners. So, do you recommend any site to know how to begin?
The description of the game (it is not really a game but it implements things that usually are in a game) is this:
Show a matrix of images of 3x3 elements, then, hide them and put instead empty squares. The images shown in the matrix, must remain in the lower part of the screen just below the empty squares and they must be randomly positioned. The user, must click one image and put it on the correct empty square. The result, must be, how many images were correctly positioned, the time it took to end the game, the time between mouse clicked and released for each image.
For additional information, I want you to know that this application is for a friend of mine who studies medicine. He wants this program to test patients who accident and receive hits on their heads. You may think that the description I gave you may not be a good software for that purpose, and in fact, it may be not, but, once I know the management of all that is required (Images, MouseListeners, how to introduce it to a web etc), I will be able to make a better product. So, please tell me, how can I begin?. What do I need to know?
I would start here. Except for some startup boilerplate and the restrictions of the sandbax (which, based on your description, you will b unlikely to encounter), there is no fundamental difference in an applet from normal code.