f



How do I get coordinates or mouse clicks C/C++, Linux?

I have a code which does it, but when it works its difficult to interact with a desktop - I need to click several times on something to access it. (prefer license which will not demand to disclose source code) Here is the link to the code which I use:

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main (){
    int x=-1,y=-1;
    XEvent event;
    int button;
    Display *display = XOpenDisplay(NULL);
    if (display == NULL) {
    fprintf(stderr, "Cannot connect to X server!\n");
    exit (EXIT_FAILURE);
    }
    Window root= XDefaultRootWindow(display);
    XGrabPointer(display, root, False, ButtonPressMask, GrabModeAsync,
         GrabModeAsync, None, None, CurrentTime);

    XSelectInput(display, root, ButtonPressMask) ;
    while(1){
    XNextEvent(display,&event);
    switch(event.type){
    case ButtonPress:
        switch(event.xbutton.button){
        case Button1:
        x=event.xbutton.x;
        y=event.xbutton.y;
        button=Button1;
        break;

        case Button3:
        x=event.xbutton.x;
        y=event.xbutton.y;
        button=Button3;
        break;
        default:
        break;

        }
        break;
    default:
        break;
    }
    if(x>=0 && y>=0)break;
    }
    if(button==Button1)printf("leftclick at %d %d \n",x,y);
    else printf("rightclick at %d %d \n",x,y);
    XCloseDisplay(display);
    return 0;
}
0
fsn761304
12/13/2015 9:06:36 PM
comp.os.linux.development.apps 5216 articles. 1 followers. Post Follow

3 Replies
376 Views

Similar Articles

[PageSpeed] 2

On 2015-12-13, fsn761304@gmail.com <fsn761304@gmail.com> wrote:
> I have a code which does it, but when it works its difficult to
> interact with a desktop - I need to click several times on something
> to access it. (prefer license which will not demand to disclose source
> code) Here is the link to the code which I use:    

QT is available for closed source IIRC, might have to pay some.
it's not pure C++ thoough

-- 
  \_(ツ)_
0
Jasen
12/14/2015 8:33:45 AM
On 13.12.15 23:06, fsn761304@gmail.com wrote:
> I have a code which does it, but when it works its difficult to interact with a desktop - I need to click several times on something to access it. (prefer license which will not demand to disclose source code) Here is the link to the code which I use:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
>
> int main (){
>      int x=-1,y=-1;
>      XEvent event;
>      int button;
>      Display *display = XOpenDisplay(NULL);
>      if (display == NULL) {
>      fprintf(stderr, "Cannot connect to X server!\n");
>      exit (EXIT_FAILURE);
>      }
>      Window root= XDefaultRootWindow(display);
>      XGrabPointer(display, root, False, ButtonPressMask, GrabModeAsync,
>           GrabModeAsync, None, None, CurrentTime);
>
>      XSelectInput(display, root, ButtonPressMask) ;
>      while(1){
>      XNextEvent(display,&event);
>      switch(event.type){
>      case ButtonPress:
>          switch(event.xbutton.button){
>          case Button1:
>          x=event.xbutton.x;
>          y=event.xbutton.y;
>          button=Button1;
>          break;
>
>          case Button3:
>          x=event.xbutton.x;
>          y=event.xbutton.y;
>          button=Button3;
>          break;
>          default:
>          break;
>
>          }
>          break;
>      default:
>          break;
>      }
>      if(x>=0 && y>=0)break;
>      }
>      if(button==Button1)printf("leftclick at %d %d \n",x,y);
>      else printf("rightclick at %d %d \n",x,y);
>      XCloseDisplay(display);
>      return 0;
> }


What are you attempting to achieve?

A clandestine mouse logger?

-- 

-TV

0
Tauno
12/14/2015 7:24:53 PM
On Monday, December 14, 2015 at 11:24:56 PM UTC+4, Tauno Voipio wrote:
> On 13.12.15 23:06, fsn761304@gmail.com wrote:
> > I have a code which does it, but when it works its difficult to interact with a desktop - I need to click several times on something to access it. (prefer license which will not demand to disclose source code) Here is the link to the code which I use:
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <X11/Xlib.h>
> > #include <X11/Xutil.h>
> >
> > int main (){
> >      int x=-1,y=-1;
> >      XEvent event;
> >      int button;
> >      Display *display = XOpenDisplay(NULL);
> >      if (display == NULL) {
> >      fprintf(stderr, "Cannot connect to X server!\n");
> >      exit (EXIT_FAILURE);
> >      }
> >      Window root= XDefaultRootWindow(display);
> >      XGrabPointer(display, root, False, ButtonPressMask, GrabModeAsync,
> >           GrabModeAsync, None, None, CurrentTime);
> >
> >      XSelectInput(display, root, ButtonPressMask) ;
> >      while(1){
> >      XNextEvent(display,&event);
> >      switch(event.type){
> >      case ButtonPress:
> >          switch(event.xbutton.button){
> >          case Button1:
> >          x=event.xbutton.x;
> >          y=event.xbutton.y;
> >          button=Button1;
> >          break;
> >
> >          case Button3:
> >          x=event.xbutton.x;
> >          y=event.xbutton.y;
> >          button=Button3;
> >          break;
> >          default:
> >          break;
> >
> >          }
> >          break;
> >      default:
> >          break;
> >      }
> >      if(x>=0 && y>=0)break;
> >      }
> >      if(button==Button1)printf("leftclick at %d %d \n",x,y);
> >      else printf("rightclick at %d %d \n",x,y);
> >      XCloseDisplay(display);
> >      return 0;
> > }
> 
> 
> What are you attempting to achieve?
> 
> A clandestine mouse logger?
> 
> -- 
> 
> -TV

I want screenshot of specific part of screen, then OCR recognition.
0
fsn761304
12/15/2015 10:31:10 AM
Reply:

Similar Artilces:

How do I get coordinates or mouse clicks C/C++, Linux the other way ?
I have a code which does it, but when it works its difficult to interact with a desktop - I need to click several times on something to access it. Here is the code which I use: #include <stdio.h> #include <stdlib.h> #include <X11/Xlib.h> #include <X11/Xutil.h> int main (){ int x=-1,y=-1; XEvent event; int button; Display *display = XOpenDisplay(NULL); if (display == NULL) { fprintf(stderr, "Cannot connect to X server!\n"); exit (EXIT_FAILURE); } Window root= XDefaultRootWindow(display); XGrabPointer(...

[News] Linux Gets Tool to Ease Development, New GNU C/C++ Toolchain
Kernel space: Bisection divides users and developers ,----[ Quote ] | Linux developers change the kernel at the rate of one patch every twenty | minutes. When you report a bug, finding the one patch that introduced it can | be trouble. A new tool lets users help find it--if kernel developers and bug | reporters can work together. `---- http://www.linuxworld.com/news/2008/042108-kernel.html?fsrc=rss-linux-news Commercial GNU tools rev'd ,----[ Quote ] | CodeSourcery has updated its commercially supported versions of the GNU C/C++ | Toolchain and Eclipse IDE (integrated developmen...

C/C++ Linux
Hey All, Wondering if anyone can help me. I am working on an assignment for an OS class. The assignment requires that I write code that will create 4 child processes, "producer", "filter1", "filter2", and "consumer". The "producer" will read data from an input text file (line by line), "filter1" will replace all " " with "*", "filter2" will replace all "CAPS" with "LOWERCASES" and the consumer will append the new modified data to a new output text file (this must be done line by line...

Linux C/C++
Can anyone suggest me a good book to learn C/C++ programming under Linux platform? Magesh wrote: > Can anyone suggest me a good book to learn C/C++ programming under > Linux platform? > Which, C or C++? They are different languages (only one of which is topical here). The platform is probably irrelevant for learning. -- Ian Collins. Magesh wrote: > Can anyone suggest me a good book to learn C/C++ programming under > Linux platform? Do you wish to learn a language or programming for a certain platform? Rui Maciel Magesh wrote: > Can anyone suggest me a good book ...

Calling all C/C++ developers who know Windows and Linux
How cool would it be if we all downloaded Wine (www.winehq.com) tried to run a Windows program and fixed at least one function that failed? mlw wrote: > How cool would it be if we all downloaded Wine (www.winehq.com) tried to > run a Windows program and fixed at least one function that failed? Disaggree strongly. You don't want to fix the function but rather to make it replicate the bugs in windows when used in a certain way. Still enthused? -- Stephen Fairchild mlw wrote: > How cool would it be if we all downloaded Wine (www.winehq.com) tried to run > a Windows program ...

[News] Linux Gets Bidirectional C/C++ Debugger
First C/C++ binaries bidirectional debugger targets Linux ,----[ Quote ] | Co-founder Julian Smith says Undo chose to release its bidirectional | debugger on Linux first because, "Today's Linux market is pretty | exciting, not least due to its rapid expansion into consumer | electronics and other embedded systems... `---- http://www.linuxdevices.com/news/NS4715550062.html ...

Sr Software Engineer needed-C,C++, DEBUG, LINUX, NETWORKS, WINDOWS OS,MFC, C#, .NET, XML,Cold Fusion/SQL
Dear All I will appreciate if you mail your updated resume asap along with your salary expectation on w2 basis Assignment Information Project Location: WA Project Name: EST - Evaluation Engineering Desired Start Date: 06/21/2004 Length of Engagement: 6 mo Shift: 01 Primary Skill: C++ Other Skills: C, DEBUG, LINUX, NETWORKS, WINDOWS OS Roles & Responsibilities Update 6/15; the client added the following skills to the Necessary MUST HAVES: 1. MFC, C#, .NET, XML, MFC 2. no change 3. no change ...

Developer/ Linux/ C,C++/ XWindows/ Contract/ Champaign, IL
Tom Gugger Independent Recruiter tgugger@bex.net Developer/XWindows/ C, C++/ Contract/ Champaign, IL US Citizen On Site Work One MUST be a US Citizen. Below is the complete job description, but the keys are XWindows/ C, C++, and some of the things listed below. The rate is $45hr, W2, and no expenses. The duration of the contract is one year. Working conditions are said to be excellent. We are now hiring. If interested and qualified, email resume to tgugger@bex,net. Job Description: We are currently seeking a Sr Software developer for the Champaign, IL based operations. This position ...

C or C++ for FOSS/linux?
C or C++, which is better to learn and improve upon for a goal of contributing to open source projects, writing linux drivers, helping with linux and FOSS in general? -- If you have walked all these days with closed ears and mind asleep, wake up now! -- Gandalf Beowulf <beowulf@wayoftheancients.net> writes: > C or C++, which is better to learn and improve upon for a goal of > contributing to open source projects, writing linux drivers, helping with > linux and FOSS in general? C. More programs are written in C than C++. You can easily find statistics. -- ...

Linux, Linux, Linux
Hi, Interested in trying Linux? Well you came to comp.os.linux.advocacy for some reason, and you probably won't stay long. Here's a list of Linux distributions to choose from. Ubuntu http://www.ubuntu.com Newbie friendly and good support forums. SuSE http://www.novell.com/linux Pay for some support if you're not opposed to spending a little money. Fedora Core http://fedoraproject.org If you're more comfortable with your computer, try this one out. If you get frustrated, don't give up so easy. There is a wealth of information online for whichever distro you choose....

JOB: Technical Leader (Linux, C/C++, Driver, OS, FreeBSD and Kernels)
* Please contact Brent at breroger@cisco.com if interested. Technical Leader Location - San Jose, CA Description NSSTG develops, tests, and manages the release of Cisco Classic IOS and IOS-XE Software, which runs on nearly eighty percent of the products that Cisco ships to customers. NSSTG collaborates closely with the rest of Cisco engineering to develop, maintain, and enhance the features and functionality that address customer needs and lead to technology breakthroughs. We are leading the transformation of software at Cisco by delivering innovations that span key areas of technology, arc...

US-NJ: South Brunswick-Programmer Analyst/Developer
************************************************************** JobCircle.com is a regional job board serving all industries and occupations in the PA, NJ, DE, NY, MD, and DC areas. We offer a regional job board, online learning, and regional job fair events for jobseekers who live in our areas of focus. To Learn More: Job Board: http://www.JobCircle.com?source=ng eLearning: http://www.JobCircle.com/courseware?source=ng Job Fairs: http://JobCircleJobFairs.com?source=ng ************************************************************** Job Title: Programmer Analyst/Deve...

Using C-h c and C-h k on mouse clicks
I can't seem to find a way to determine what function is assigned to mouse double-click events. C-h c or k shows the single click function only. rgb wrote: > I can't seem to find a way to determine what function is > assigned to mouse double-click events. C-h c or k shows > the single click function only. I looked into this further and discovered that the single click function was actually looking at the click count and taking different actions based on the number of clicks. So, apparently, there is no such thing as a double-click event. ...

A command line C++ code generator, which makes Unix/Linux C++ development faster.
fgen is a free command line tool that facilitates cross platform c++ development, including header generation, cpp file generation, makefile generation, unit test framework generation, etc. http://sf.net/projects/fgen It's written in Python, and there is a linux executable to download. Hope it helps some people! ...

Web resources about - How do I get coordinates or mouse clicks C/C++, Linux? - comp.os.linux.development.apps

Curvilinear coordinates - Wikipedia, the free encyclopedia
In geometry , curvilinear coordinates are a coordinate system for Euclidean space in which the coordinate lines may be curved. These coordinates ...

Iraq, Russia, Iran and Syria coordinate against ISIL
While Iraq has officially announced it is sharing intelligence with Russia, Syria and Iran, the cooperation is not new.

ISIS may use PlayStation 4s to coordinate Paris-like attacks
Late on Friday night, Paris was brutally hit in a highly coordinated terrorist attack that ISIS later claimed responsibility for planning. At ...

OPEN BORDERS IDIOCY: Rubio, Ryan and Graham Coordinate Attack on Trump over Islamic Immigration
By Julia Hahn The Speaker of the House and two presidential candidates—all of whom have supported amnesty and immigration expansions—are coming ...

Abortion Humor: Hillary and Cecile To Coordinate Pantsuits
Planned Parenthood has endorsed Hillary Clinton for president following Congress' vote to defund the abortion business.

Cabinet Said to Create Body to Coordinate Affairs of Financial Regulators
Secretariat to focus on aiding cooperation between the central bank and main financial regulators, people close to matter say

Leaked Docs: Dems Coordinate To Discredit EPA Critics
'Denying [electricity] rate increases strains credulity with many audiences'

ISIS Taps Dark Web, Encryption Apps to Coordinate
ISIS and other terrorists are able to communicate under the radar of Western intelligence agencies.

Pogo wins $1M in Verizon contest with an app to help parents coordinate carpools
... plans to release its app in early 2016. The idea is to give parents the information they need to share more rides. Pogo can be used to coordinate ...

US Peacekeeping Expert to Coordinate Sexual Abuse Response
The United Nations secretary-general has appointed a U.S. security expert to coordinate improvements in the U.N.'s response to reports of sexual ...

Resources last updated: 2/9/2016 1:26:35 AM