LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Counting mouse clicks/movement and keyboard presses? (https://www.linuxquestions.org/questions/programming-9/counting-mouse-clicks-movement-and-keyboard-presses-334596/)

breadcrust 06-17-2005 11:15 AM

Counting mouse clicks/movement and keyboard presses?
 
I am working on a Tcl UNIX client for SigX called TclSigX at the moment.

Basiclly what the client does is retrieve user and system stats from the computer it is installed in, format it so it looks neat and readable and send it to the SigX server, every couple of minutes. SigX then generates and updates an image with these statistics writen onto it, and you can use that image on a forum or email signature.

Anyway, I wanted to impliment a feature similar to one that the Windows clients have, which is to count the number of times the mouse has been clicked, scrolled and how far it has been moved, and how many times keys on the keyboard has been pressed.

As there are no (or at least stable) APIs to X for Tcl, the only solutions I can see to this problem is figuring this stuff out via some command, or making up a [C] helper program to come with TclSigX. I'd like to avoid making up a helper.

So, would anyone be able to help me out a bit here?

zulfilee 06-20-2005 08:23 AM

Hey I `ve seen one such utility
Its a command by name
xev

And it does the job pretty well.It gives me the statistics of mouse click , release
Keyboard press,etc
But I am not sure whether its there in Tcl Unix or not.

Cheers
Z

hamedhsn 01-21-2011 01:12 AM

Quote:

Originally Posted by zulfilee (Post 1704964)
xev

And it does the job pretty well.It gives me the statistics of mouse click , release
Keyboard press,etc
Z

could you show example of how to use it to achieve that result i really need it.
thanks

zulfilee 01-21-2011 01:19 AM

Running just xev on the command prompt will create a window
If u click on the window the X,Y coordinates and the type of click will be displayed.

You can also use xev to get mouse related info from an existing window.

Ex:
You have a Xterm and you want to get mouse related info from that window

Go to the xterm

Type

xwininfo

THis will give you the windows id.

Then use

xev -id <windows_id>

to track the evens from window with window id <windowid>

zulfilee 01-21-2011 01:28 AM

Also there is another command line tool call xmacro.

Its used for recording keyboard and mouse events and replay them.

I guess it should be useful for your query


Install xmacro [its a very small utility]

Run
xmacrorec2

Click the mouse anywhere and see the Button Number and coordinated getting logged.

Aquarius_Girl 01-21-2011 02:05 AM

Quote:

Originally Posted by breadcrust (Post 1700720)
I am working on a Tcl UNIX client
....
Anyway, I wanted to impliment a feature similar to one that the Windows clients have, which is to count the number of times the mouse has been clicked, scrolled and how far it has been moved, and how many times keys on the keyboard has been pressed.
....
So, would anyone be able to help me out a bit here?

Google told me TCL is a language, but I don't know what is "Tcl UNIX"

You can write an interrupt handler for keyboard strokes:
http://www.linuxquestions.org/questi...2/#post3771000

This one runs from the user space, but it has termios struct, see for yourself if that works in your case.
http://www.linuxquestions.org/questi...1/#post3956458

and look at this too:
http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html

Aquarius_Girl 01-21-2011 02:42 AM

:doh::doh: Now I realize the thread is from 2005!

hamedhsn 01-22-2011 09:11 AM

Quote:

Originally Posted by zulfilee (Post 4232581)
Install xmacro [its a very small utility]

Run
xmacrorec2

i am using opensuse 11.2 and i have to install xmacro with tar.gz file and when first i use make command i 'v got some errors and i dont know why?and how can i resolve it?
this part of the errors:
Code:

xmacroplay.cpp: In function ‘void eventLoop(Display*, int)’:                                                                   
xmacroplay.cpp:336: error: ‘cin’ was not declared in this scope                                                                 
xmacroplay.cpp:340: error: ‘cout’ was not declared in this scope                                                               
xmacroplay.cpp:340: error: ‘endl’ was not declared in this scope                                                               
xmacroplay.cpp:346: error: ‘cout’ was not declared in this scope                                                               
xmacroplay.cpp:346: error: ‘endl’ was not declared in this scope                                                               
xmacroplay.cpp:352: error: ‘cout’ was not declared in this scope                                                               
xmacroplay.cpp:352: error: ‘endl’ was not declared in this scope                                                               
xmacroplay.cpp:358: error: ‘cout’ was not declared in this scope                                                               
xmacroplay.cpp:358: error: ‘endl’ was not declared in this scope                                                               
xmacroplay.cpp:364: error: ‘cout’ was not declared in this scope                                                               
xmacroplay.cpp:364: error: ‘endl’ was not declared in this scope                                                               
xmacroplay.cpp:370: error: ‘cout’ was not declared in this scope
xmacroplay.cpp:370: error: ‘endl’ was not declared in this scope
xmacroplay.cpp:376: error: ‘cout’ was not declared in this scope
xmacroplay.cpp:376: error: ‘endl’ was not declared in this scope
xmacroplay.cpp:382: error: ‘cout’ was not declared in this scope
xmacroplay.cpp:382: error: ‘endl’ was not declared in this scope
xmacroplay.cpp:385: error: ‘cerr’ was not declared in this scope
xmacroplay.cpp:395: error: ‘cout’ was not declared in this scope
xmacroplay.cpp:395: error: ‘endl’ was not declared in this scope
xmacroplay.cpp:398: error: ‘cerr’ was not declared in this scope

i really need to install it.thanks for your help

acid_kewpie 01-23-2011 02:29 PM

Quote:

Originally Posted by Anisha Kaul (Post 4232656)
:doh::doh: Now I realize the thread is from 2005!

And then people slag moderators off for pointing this out to people dragging it up from the dead. But instead you've ended up being tricked into wasting your time trying to help someone from 5 years ago...

wje_lq 01-23-2011 03:03 PM

Quote:

Originally Posted by acid_kewpie (Post 4235187)
And then people slag moderators off for pointing this out to people dragging it up from the dead. But instead you've ended up being tricked into wasting your time trying to help someone from 5 years ago...

Well, no. They're also helping hamedhsn, who expressed an interest in the solution within the last day or so. He has taken over the mantle of the original poster.

Aquarius_Girl 01-23-2011 07:31 PM

Quote:

Originally Posted by hamedhsn (Post 4234009)
Code:

xmacroplay.cpp: In function ‘void eventLoop(Display*, int)’:                                                                   
xmacroplay.cpp:336: error: ‘cin’ was not declared in this scope                                                                 
...


Try adding using namespace std; at the top of the file named 'xmacroplay.cpp', see if you get any different errors this time?

---------- Post added Jan 24th, 2011 at 07:02 ----------

Quote:

Originally Posted by acid_kewpie (Post 4235187)
And then people slag moderators off for pointing this out to people dragging it up from the dead.

But in this case the first helper is still active, so yet there is no reason for the thread closure ;)


All times are GMT -5. The time now is 08:26 AM.