LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-20-2011, 07:38 AM   #1
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Rep: Reputation: 0
urgent-need to get the number of left-right-double click


hi everybody
can any one tell me how can i get the ocuurance of left click-right click-double click?
i need the time of ocurance and the click(left-right-double) that happend.
any software?
any clue..
i need it in linux environment(kde or gnome)
i appreciate you if you help me.
thanks

Last edited by hamedhsn; 01-20-2011 at 07:40 AM.
 
Old 01-20-2011, 08:52 AM   #2
SonnySee
Member
 
Registered: Aug 2010
Distribution: Unbuntu 11.10 beta
Posts: 78

Rep: Reputation: 10
Perhaps the command line utility xev will work for you.

Here is a link to the man page: http://www.unix.com/man-page/All/1/XEV/

Hope this helps.
Cheers
 
Old 01-20-2011, 10:31 AM   #3
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
It would probably help if you told us what programming language and utilities you're using...
 
Old 01-20-2011, 11:27 PM   #4
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Original Poster
Rep: Reputation: 0
thanks SonnySee and Snark1994 for you response.
i went through xev but it can not give what i want. it just creat a window and within that every event captured. i need the clicks for every window running.
in man page it says that "You can also attach it to an existing window" how it can be done??maybe if i can attach it to the active window i am able to catch click event but how it is possible???

since i needed the events happening for each window running, i already went through xlib programming (c language) i achieved what i wanted except this mouse click,right and double click.
so i was loking for another way to do that.
 
Old 01-21-2011, 05:16 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by hamedhsn View Post
can any one tell me how can i get the ocuurance of left click-right click-double click?
Hit out Google with the following keywords:
Quote:
interfacing with mouse Linux
 
Old 01-22-2011, 03:45 AM   #6
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
XCreateSimpleWindow returns a window id that is unique to this program.
SOURCE:http://www.xmission.com/~georgeps/do..._Beginner.html
I don't know what methods you're using, but I'm sure there will be an analogous return value or method to obtain it however you create your windows. You can then run xev with the -id option to attach it to your window.

@Anisha: I tried your search, most of the results seemed to be about curses, except for one which was the man page for the Linux mouse driver. Was there a specific link you were trying to direct the OP to?
 
Old 01-22-2011, 03:53 AM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by Snark1994 View Post
@Anisha: I tried your search, most of the results seemed to be about curses, except for one which was the man page for the Linux mouse driver. Was there a specific link you were trying to direct the OP to?
I wanted to point him to the first link which showed how to interact with the mouse through ncurses. Interacting with mouse means dealing with clicks so there could be a way to count the clicks from left right buttons. If I am wrong in judging the ncurses feel free to correct me.
 
Old 01-22-2011, 02:30 PM   #8
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Original Poster
Rep: Reputation: 0
hi
this is simple program regarding your help it seems really good but when i run it nothing happend.what is the problem with it??

Code:
#include <stdio.h>
#include <string.h>
#include <ncurses.h>

#define WIDTH 30
#define HEIGHT 10 

int startx = 0;
int starty = 0;


int main()
{	int c, choice = 0;
	WINDOW *menu_win;
	MEVENT event;

	mousemask(ALL_MOUSE_EVENTS, NULL);
	
	while(1)
	{
			if(getmouse(&event) == OK)
			{	/* When the user clicks left mouse button */
				if(event.bstate & BUTTON1_CLICKED)
					printf("left click\n");

			}
	}		
}
 
Old 01-22-2011, 08:02 PM   #9
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by hamedhsn View Post
this is simple program regarding your help it seems really good but when i run it nothing happend.what is the problem with it??
I am NOT a ncurses expert, what ever the problem with that program is and whatever errors you facing should be in a new thread in the programming section, then perhaps someone can help you that program.
 
Old 01-22-2011, 08:11 PM   #10
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
  1. If you're using ncurses, you need to read the ncurses man page to see how that needs to be initialized before you use any mcurses capabilities.
  2. In the man page for mousemask(), it warns that under certain conditions, the function will return a particular value which indicates that mousemask() won't do anything for you in your particular operating environment.
So read both man pages, initialize ncurses properly, and check the result returned from mousemask().
 
Old 01-23-2011, 08:14 AM   #11
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Also, you can't printf from ncurses - stdout is being screwed around with to show the curses windows, so you can't print. The best I've found is printing to a file (which you could then view with tail -f in another terminal). You also need to call a whole load of functions to initialise curses (namely; "initscr()", "clear()", "noecho()", "cbreak()"). Like Anisha said, if you're having problems with ncurses, ask in another thread. Also, re-reading post #4, you want to capture every click (ie. in all windows), which is something that may not be possible using ncurses. Even with xev you would have to find the IDs of all running windows...

EDIT:
Links... Mouse howto and introduction + compiling instructions

Last edited by Snark1994; 01-23-2011 at 08:16 AM.
 
Old 01-23-2011, 10:14 AM   #12
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Also see if struct termios can be of some use here:
http://www.faqs.org/docs/Linux-HOWTO...ing-HOWTO.html

Quote:
you want to capture every click (ie. in all windows), which is something that may not be possible using ncurses.
and I think, hamedhsn, you should first of all confirm the above quote by snark by asking it explicitly in a new thread!

Last edited by Aquarius_Girl; 01-23-2011 at 10:50 AM.
 
Old 01-23-2011, 10:54 AM   #13
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Original Poster
Rep: Reputation: 0
thanks anisha and snark
Quote:
you want to capture every click (ie. in all windows), which is something that may not be possible using ncurses.
do you have any idea how can i get it,any tools or programming??
unfortunatly, i have not found a way to solve this problem, i just left with it and i dont know what to do??

i was also trying to work with a tools (xmacro) also i had problem in this thread
http://www.linuxquestions.org/questi...71#post4232571
 
Old 01-23-2011, 11:07 AM   #14
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by hamedhsn View Post
do you have any idea how can i get it,any tools or programming??
Do you understand what does it mean when I say ask about that quoted remark explicitly in a new thread?

and did you look up on struct termios as mentioned in post 12?

Last edited by Aquarius_Girl; 01-23-2011 at 11:14 AM.
 
Old 01-24-2011, 12:07 AM   #15
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Original Poster
Rep: Reputation: 0
i created a thread.

Quote:
and did you look up on struct termios as mentioned in post 12
yeah but i did not get anything.plus xmacro also does not work.
 
0 members found this post helpful.
  


Reply



Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Single-click, double-click icons in KDE Doug Vitale Linux - Newbie 6 06-11-2015 10:09 AM
Single mouse click acts as a double click Aquarius_Girl Linux - Hardware 9 08-31-2010 01:50 AM
Fedora 9 Core Single Click acts like Double Click. solutionsville Linux - Hardware 10 12-08-2008 10:25 AM
left click on kubuntu desktop (on laptop) brings up middle click menu =S darksmiley Ubuntu 2 06-14-2008 05:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration