Input when application not active

hello,

i am writing a VOIP software for the mac. we're porting our windows code base to mac and one piece of functionality we support on windows is a push-to-talk key that you can press and talk regardless of which application currently has focus. we managed this through directinput and getasynckeystate.

i was wondering how to accomplish this functionality on mac? we use Qt for our UI components. we had tried using SDL however in order to capture the input your window needs to be the active window.

any assistance anyone could give us would be greatly appreciated.

MBP 2.0GHZ, Mac OS X (10.5.4)

Posted on Aug 20, 2008 10:44 AM

Reply
8 replies

Aug 20, 2008 1:47 PM in response to musikit

from what i have been able to discover in order to get input while other applications are active i need to have "enable access for assistive devices" enabled.

can anyone please point me to the framework or an example that lets me check if this is enabled (so i can tell my users) and receive the input while another app is active?

thank you

Aug 21, 2008 6:36 AM in response to musikit

One of the limitations of the SDK is that there is no concept of an application having "focus". An application is either running or it is not. When another application starts your application will stop, so you will not be able to receive any input at all. If your application does not shut down upon receiving the applicationWillTerminate message (which is sent when another application is launched), the OS has a watchdog that will kill your application.

There are two exceptions that I am aware of in the above-- the iPod application can run in the background and the phone application can run in the background. Third party applications can not.

rob.

Aug 22, 2008 7:49 AM in response to musikit

ok i've been search for this for several days now and i continue to hit stuff that are possibles but arent really stating "this is what i want"

again we use Qt so Qt is the one that is initializing NSApplication. i'm not initializing NSApplication.

however what it seems i want is something called a CGEventTap????
http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef /Reference/reference.html

but im still looking for the api function to detect weather "enable access for assistive devices" is checked or unchecked so i can inform the user via a popup to enable it and/or autolaunch systempreferences so the user can set it.

again what im looking to do is listen (and get a callback) whenever mouse/keyboard events happen regardless of weather i am the application that has focus or not so i can provide a system to my users for system wide hotkeys they define.

if anyone could please please please confirm "yeah thats what you want" to "no you dont want that" i would very much appreciate it.

Sep 30, 2009 6:18 AM in response to musikit

finally figured this out.

this is a two part issue.

use http://developer.apple.com/samplecode/EventMonitorTest/index.html to get input when application is not active. documentation says that the "enable assistance devices" is not accessible for reading. but after a lot of digging found AXAPIEnabled() which will indicate that checks state.

to get input when you application is active. you will have to override NSApplication and override sendEvent.

using these two mechanisms you will be able to get key/mouse state regardless of what NSView/application is the current focus.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Input when application not active

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.