Tracking key presses, mouse clicks and mouse movements? 
Author Message
 Tracking key presses, mouse clicks and mouse movements?
Is there a way in RB to grab the keyboard state (ie, are any keys
pressed), mouse button state and mouse cursor position?  Or will I have
to resort to direct calling of Toolbox routines to do this?

(I found the Keyboard object, but that just seems to be able to test
certain keys to see if they're down -- I want to find out if ANY keys
are down, and don't really care what they are.)



Sun, 31 Aug 2003 03:32:09 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> (I found the Keyboard object, but that just seems to be able to test
> certain keys to see if they're down -- I want to find out if ANY keys
> are down, and don't really care what they are.)

Just test for all in a for-next loop.

Mfg
Christian

--
Wenn schon zuwenig Vitamine, dann wenigstens t?glich einen Apple.

http://www.christians-software.de (Kostenlose Mac/Win Software)



Sun, 31 Aug 2003 03:35:19 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> > (I found the Keyboard object, but that just seems to be able to test
> > certain keys to see if they're down -- I want to find out if ANY keys
> > are down, and don't really care what they are.)

> Just test for all in a for-next loop.

That's not exactly the kind of thing I want to be doing once a second...


Sun, 31 Aug 2003 07:05:21 GMT  
 Tracking key presses, mouse clicks and mouse movements?


Quote:


>> > (I found the Keyboard object, but that just seems to be able to test
>> > certain keys to see if they're down -- I want to find out if ANY keys
>> > are down, and don't really care what they are.)

I missed the beginning of th thread, so please excuse me if this is a rehash
of something already said, but isn't that what the KeyDown event is for?

Jeff



Sun, 31 Aug 2003 07:26:30 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> Is there a way in RB to grab the keyboard state (ie, are any keys
> pressed), mouse button state and mouse cursor position?  Or will I have
> to resort to direct calling of Toolbox routines to do this?

Check out the System object in the documentation. It gives you mouse
coordinates and button state.

Quote:
> (I found the Keyboard object, but that just seems to be able to test
> certain keys to see if they're down -- I want to find out if ANY keys
> are down, and don't really care what they are.)

The next obvious question is: Why do you want this information? You
might be trying to do something that RB already does, but you just don't
know about it.

--
"In a world full of lies / which tug at the truth
 I'm taking no sides... now I recognize you." -DS



Sun, 31 Aug 2003 07:34:15 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:



> > > (I found the Keyboard object, but that just seems to be able to test
> > > certain keys to see if they're down -- I want to find out if ANY keys
> > > are down, and don't really care what they are.)

> > Just test for all in a for-next loop.

> That's not exactly the kind of thing I want to be doing once a second...

Why not?  It'll take a few ticks at most.

Or, declare a call to GetKeys if you really think it's worth it (but I
doubt it is).

As to your other questions: look at System.MouseX, .MouseY, and
.MouseDown.

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sun, 31 Aug 2003 07:57:48 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> Check out the System object in the documentation. It gives you mouse
> coordinates and button state.

Perfect!  I didn't find this object before.  Thanks!

Quote:
> The next obvious question is: Why do you want this information? You
> might be trying to do something that RB already does, but you just don't
> know about it.

I'm trying to track user events/second, even when by app is in the
background (which is most of the time).  It's for an RSI (Repetitive
Stress Injury) prevention tool.


Sun, 31 Aug 2003 22:54:30 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> > That's not exactly the kind of thing I want to be doing once a second...

> Why not?  It'll take a few ticks at most.

You're right -- I did a test and timed it, and at most it took 1 tick
to complete.  I guess RB can do things faster than I expected.

However, what key codes should I check?  I wasn't thinking too clearly
at first and checked 0 through 255 and 41 keys were returned as being
down each time.  But those aren't key codes, they're ASCII codes!

I found a diagram of key code in the Language Reference that seemed to
imply that 7D (125) is the highest key code that may be returned (not
counting the power key, which I don't think I'm interested in tracking
anyway).  Is this correct on all keyboards?



Sun, 31 Aug 2003 23:14:28 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:





> >> > (I found the Keyboard object, but that just seems to be able to test
> >> > certain keys to see if they're down -- I want to find out if ANY keys
> >> > are down, and don't really care what they are.)

> I missed the beginning of th thread, so please excuse me if this is a rehash
> of something already said, but isn't that what the KeyDown event is for?

> Jeff

The thread started as follow:

Is there a way in RB to grab the keyboard state (ie, are any keys
pressed), mouse button state and mouse cursor position?  Or will I have
to resort to direct calling of Toolbox routines to do this?

(I found the Keyboard object, but that just seems to be able to test
certain keys to see if they're down -- I want to find out if ANY keys
are down, and don't really care what they are.)



Mon, 01 Sep 2003 00:41:32 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:



> > > That's not exactly the kind of thing I want to be doing once a second...

> > Why not?  It'll take a few ticks at most.

> You're right -- I did a test and timed it, and at most it took 1 tick
> to complete.  I guess RB can do things faster than I expected.

> However, what key codes should I check?  I wasn't thinking too clearly
> at first and checked 0 through 255 and 41 keys were returned as being
> down each time.  But those aren't key codes, they're ASCII codes!

> I found a diagram of key code in the Language Reference that seemed to
> imply that 7D (125) is the highest key code that may be returned (not
> counting the power key, which I don't think I'm interested in tracking
> anyway).  Is this correct on all keyboards?

In the iMac, for example, there is less keys than on an extended keyboard.
Personaly, I check until 130. And I believe that you can't count the power key.


Mon, 01 Sep 2003 00:45:32 GMT  
 Tracking key presses, mouse clicks and mouse movements?

Quote:

> I found a diagram of key code in the Language Reference that seemed to
> imply that 7D (125) is the highest key code that may be returned (not
> counting the power key, which I don't think I'm interested in tracking
> anyway).  Is this correct on all keyboards?

Yes, the key diagram has all possible keys.  Some keyboards will have
fewer, but there should be no harm in checking the state of nonexistent
keys.

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Mon, 01 Sep 2003 02:27:26 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Mice, mice, mice, mice ...

2. Mice, mice, mice, mice ...

3. Move mouse-cursor and send mouse-click

4. Key presses, clicks and double clicks.

5. How do I restrict mouse cursor movement area?

6. Controlling mouse movement under OSX

7. Mouse movement

8. Mouse X , Y movement

9. Win2K and mouse movement --> crash

10. Fixed: W2K GPF at any mouse movements

11. Win2000, Inkey() and Mouse Movements

12. How to detect mouse movement/key press on Mac?

 

 
Powered by phpBB® Forum Software