Coder Social home page Coder Social logo

Comments (8)

kwhat avatar kwhat commented on July 29, 2024

Hi,

The only way to test for accessibility is to register the native hook and
see if it throws an exception. If you get an exception, you should be able
to check the error code for accessibility. The error codes are defined in
the NativeHookException, See
https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/NativeHookException.java#L98

If you need better control of the accessibility API, you will need to
create an OSX only JNI or JNA library to handle that functionality. Its
out of scope for this library because it only pertains to OSX.

Best Regards,
Alex

On Mon, May 18, 2015 at 10:01 AM, kaseriya [email protected] wrote:

Thank you very much for this awesome library.
Is there any way to check whether user has allowed the accessibility for
the app?

When i run my app on the OS X, it asks for accessibility permission
(Accessibility API is disabled!) and dialog box opens. If user does not
allow accessibility, so i can display the message to allow the
accessibility.

Thanks!!


Reply to this email directly or view it on GitHub
#51.

from jnativehook.

MrPingPong avatar MrPingPong commented on July 29, 2024

Hi,
Thanks for your quick reply,
In this case, no exception is being thrown. I see following logs

May 19, 2015 1:43:14 AM org.jnativehook.GlobalScreen$NativeHookThread enable
SEVERE: hook_run [1122]: Accessibility API is disabled!

from jnativehook.

kwhat avatar kwhat commented on July 29, 2024

That is definitely a bug, an exception should be raised. What version are you using?

from jnativehook.

MrPingPong avatar MrPingPong commented on July 29, 2024

i am using 2.0.1

from jnativehook.

kwhat avatar kwhat commented on July 29, 2024

This should fix it.

JNativeHook-2.0.20150523.zip | uploaded via ZenHub

from jnativehook.

MrPingPong avatar MrPingPong commented on July 29, 2024

It works fine now. Thanks!!

If possible then please throw some specific exception (AccessibilityException) instead of generic exception "NativeHookException" for this case.

from jnativehook.

kwhat avatar kwhat commented on July 29, 2024

Its possible, but all of the specific exceptions would be platform dependent. NativeHookException would still need to exist, there would just be several exception wrappers for the platform dependent items. I was originally going to implement it that way, but I don't really see a clear benefit of having the platform dependent exceptions at the library level. I came to that conclusion because all but two of the exception types, DARWIN_AXAPI_DISABLED and X11_RECORD_NOT_FOUND are unrecoverable. Furthermore, the AXAPI exception is the only one that can realistically recover at run-time, but the library does not provide a facility for doing so, again because it would be highly platform specific. I always imagined that if someone wanted to recover on OS X, the implementing application could catch the NativeHookException, check the code for DARWIN_AXAPI_DISABLED and then throw an AccessibilityException and/or ask the OS for accessibility access via JNI/JNA. If you have a different program flow in mind, please let me know. Many excellent suggestions have come from user feedback.

from jnativehook.

MrPingPong avatar MrPingPong commented on July 29, 2024

ohh my bad! I dint notice that NativeHookException has native error codes as well.
thanks!

from jnativehook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.