I am using the below code to get the pointer location but windows 10 blocks the access as I run the application.
while (true) {
//Thread.sleep(100);
try {
System.out.println("(" + MouseInfo.getPointerInfo().getLocation().x
+ ", "
+ MouseInfo.getPointerInfo().getLocation().y + ")");
} catch (Exception e) {
e.printStackTrace();
}
Error:
A notification pops up in the notification panel saying:
Unauthorized Changes blocked Controlled folder access blocked netbeans64.exe from making changes.
It was working fine before accessing the pointer location. There's no exception thrown by e.printstacktrace()
. What am I supposed to do?
Update
If I allow it from the Defender settings, I'm able to access the pointer location. How can I enable it from Java? it will lead every person using the app to allow it from Defender Settings which doesn't seem quiet right. Any Ideas please?