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 > Counting keystrokes...

Counting keystrokes...
Thread Tools
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 13, 2003, 02:38 PM
 
Hello,

I'm not sure if any of you were ever familiar with Project-Dolphin, now Project-Orca, just basically a project where you download a program to run and it counts how many keys you type, as a fun little statistic, nothing too useful.

There never was a Mac OS X client to interface with the project, so for fun I've been trying to figure out how to go about to create one. Right now though I am at a loss for finding a good way to perform an action upon a keystroke being pressed, with Windows you can set hooks, but with Mac OS X, I am not really sure.

I would appreaciate any ideas on how to handle that aspect.

Thanks for any assistance,

Charles
     
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 14, 2003, 09:03 PM
 
Not meaning to sound like I'm rushing... perhaps I should explain better.

The program would be running in the dock, where everykeystroke would be counted. What would you all consider to be the best way to call a method like updateCount when a keystroke is pushed?
     
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 15, 2003, 04:33 PM
 
Okay, anyone at least know what class I should subclass to override the keyDown event to perform my own stuff?

The program will just be running in the dock during the duration the computer is running, and every keystroke would be counted, so any ideas on what class I should subclass?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 16, 2003, 12:27 AM
 
Originally posted by Charles.OBrien:
Okay, anyone at least know what class I should subclass to override the keyDown event to perform my own stuff?

The program will just be running in the dock during the duration the computer is running, and every keystroke would be counted, so any ideas on what class I should subclass?
I think you've pretty much hit on the reason nobody has answered your question--it can't be done that simply. Your application doesn't ordinarily receive keystrokes intended for other applications, so it has no way of counting them. I don't know of any Carbon call for it either (though that doesn't mean there isn't one), so I'd say your best bet would be an APE. If you don't want that, there's probably something in IOKit that could do it, but I couldn't be much more specific.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 16, 2003, 07:44 AM
 
I started to figure that was the case... thank you much, I'll take a look into what you suggested.

Charles
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 16, 2003, 08:51 AM
 
it can't be done that simply
Thank goodness for that. I'd rather not have every malcontent trying to infest my system with keyloggers.
     
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 16, 2003, 10:27 AM
 
So, I am just trying to create this to be malicious? Not everything like this is meant for that sort of purpose, nor would it even be logging the specific keystroke but rather just up a quantity.

Now, I would like this topic to be locked... I have recieved my answer, and now people are reducing this to that of a malicious keylogger...

- Charles
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 16, 2003, 05:37 PM
 
Charles,

I never stated or implied that you wanted to make a malicious keylogger. You stated your intentions in the first post of this thread, and I have no reason not to believe you.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 16, 2003, 06:58 PM
 
Originally posted by Charles.OBrien:
So, I am just trying to create this to be malicious? Not everything like this is meant for that sort of purpose, nor would it even be logging the specific keystroke but rather just up a quantity.
I think int69h was just commenting on why it's generally a good thing that Apple makes this difficult, not talking about your case in particular.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Feb 16, 2003, 07:29 PM
 
The good news? Apple provides hooks for generic keyboard input components -- these hooks are used by their own input methods (which is how you can type Japanese or Chinese without a 10,000-key keyboard; see the Input Menu pane of International Preferences) and are available for third parties (which often use them for things like input devices for the disabled).

The bad news? There are two APIs for this: a Cocoa one that's easy to write to but only covers Cocoa apps, and a yucky old Carbon API that applies to input in all applications.

For the former, look here. For the latter, see this documentation.
Rick Roe
icons.cx | weblog
     
Grizzled Veteran
Join Date: Jun 2001
Location: Seattle
Status: Offline
Reply With Quote
Feb 17, 2003, 12:47 AM
 
Originally posted by Rickster:
...and a yucky old Carbon API that applies to input in all applications.
So if apple were to implement a log-out w/o quitting ala windows, could these programs still grab keystrokes?
~BS
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Feb 17, 2003, 03:18 AM
 
That, of course, would depend on how they implemented it.
Rick Roe
icons.cx | weblog
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:47 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2