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.

Jakob Pogulis
  • 1,150
  • 2
  • 9
  • 19
  • Maybe this will help: http://stackoverflow.com/questions/480866/get-the-title-of-the-current-active-window-document-in-mac-os-x – martinez314 Mar 28 '13 at 21:06

1 Answers1

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.

CodeChimp
  • 8,016
  • 5
  • 41
  • 79
  • Thanks I'll look into that. The real purpose of the application is really a user study in biometrics based on this research (http://www.csis.pace.edu/~ctappert/it691-11fall/projects/mouse-pusara.pdf). – Jakob Pogulis Mar 28 '13 at 20:05
  • You might also reference [rococoa](http://code.google.com/p/rococoa/) which provides some cocoa-specific bits if you need Objective-C support above and beyond what JNA's C-compatible bindings get you. – technomage Mar 28 '13 at 20:26