1

I'm writing an application to collect information about a users behavior in front of the computer in order to study usage patterns. I've looked into JNA but can't find any information about how to capture the active application for platforms other than Windows.

  • Are there any libraries (such as JNativeHook) to capture the active application in OSX?

I would like to capture the active application rather than the active window title in order to avoid integrity concerns for the user study. Also, I know that Java is not really meant to work outside the JVM and capture this sort of things, but since there are a lot of database interaction and a limited amount of time Java was chosen and the project is completed except for this component.

1

1 Answer 1

0

Sure, for a "user study" ;) ;)

In Objective-C, you would do something like:

NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']

I may be off on the exact code, as I don't have access to a Mac right now, and doing that from memory/APIs, but I think that is close. The important starting point is NSWorkspace. Now, how you go about calling that using JNA, I haven't the foggiest.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.