Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Intercepting Keystrokes and Mouse clicks

Intercepting Keystrokes and Mouse clicks
Thread Tools
iChristopher
Mac Enthusiast
Join Date: May 2002
Location: Cincinnati, OH
Status: Offline
Reply With Quote
May 27, 2002, 04:11 PM
 
Back "in the day" I could use System Extensions to do tricky stuff like watch what the user is typing or clicking in any application. Now I don't know where to start with this kind of thing.

In summary, I want to capture "Command-P" or the selection of "Print..." from a specific application, do some stuff and then discard the event before the application recieves it.

Does this make sense?

Has anybody seen any code examples of something like this? I'd probably want to run as a Daemon, if I understand Daemons and how they work correctly. Of course, I don't know how to get my Daemon to see what apps are running, and filter these specifc events if the app it's looking for is running.

I don't necessarily want you to write the code for me! I just need to be pointed to some good reference material so I at least know where to start.

Thanks very much in advance...
TiBook 667 DVI - 20" Cinema Display - 20GB iPod
     
parallax
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 27, 2002, 05:43 PM
 
You can capture modifier sequences using Carbon HotKeys. Otherwise I think you'll need to write a kext or somethin'.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
iChristopher  (op)
Mac Enthusiast
Join Date: May 2002
Location: Cincinnati, OH
Status: Offline
Reply With Quote
May 27, 2002, 06:04 PM
 
Thanks for the reply.

Now I have to expose myself as a complete boob. What is "Carbon HotKeys"? Is this an application, a code example, an Apple library, a new Subway sub? <img border="0" title="" alt="[Wink]" src="wink.gif" />

I tried a Google search on variations and hunches, but I didn't find anything relevant. I was really hoping to find something so I would have to come back here and be stupid.
TiBook 667 DVI - 20" Cinema Display - 20GB iPod
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 28, 2002, 04:10 PM
 
He means the "HotKey" API in Carbon. It involves calls like RegisterUniversalHotKey() or something. I'm not sure how well it interfaces with Cocoa in current releases of OS X, though.
     
macrophyllum
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
May 30, 2002, 03:27 PM
 
Does anyone know how to intercept mouse and key stokes using the Cocoa API's? Someone suggested using the NSEvent class, I looked at it, but didn't no where to start.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 30, 2002, 11:56 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by macrophyllum:
<strong>Does anyone know how to intercept mouse and key stokes using the Cocoa API's? Someone suggested using the NSEvent class, I looked at it, but didn't no where to start.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Well, I'm no uber-guru or anything, but I don't think there's anything in the Cocoa API for doing that.
NSEvent does something similar, but it's not quite what you're asking for. As far as I know, NSEvents are for letting objects in an application respond to certain events in that application. I don't think you can normally get NSEvents from another application.
The only way I know of to do the sort of thing it sounds like you're wanting is, like they said, Carbon Events. Sorry. (That is, unless you can find a way to get your class into the app or something.)
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:13 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,