Thread: How to move mouse and click, or write. C++

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    8

    Red face How to move mouse and click, or write. C++

    Hi everybody!

    Im am new to C++. I like it very mutch and I have a tiny litle question I want to ask you.
    I want to know how i move the mouse cursor and click with it, or mabey write with it.
    I have search for it, and i just find for WinAPI. Im using Linux and Xlib. But if there a better way, just say it

    That i gonna do is
    1. Move mouse to a blank URL-textbox.
    2. Press left-click (or right click sometimes).
    3. The C++ is gonna press "CTRL-V" and paste an Url (or just write).

    Chears!
    Last edited by heretic; 07-09-2011 at 01:37 PM.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Im using Linux and Xlib. But if there a better way
    Depending on how much C++ you've managed to grasp, there are several libraries that would do it.
    Look for C++ Gui Libraries for linux (most of them are portable ).

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Quote Originally Posted by manasij7479 View Post
    Depending on how much C++ you've managed to grasp, there are several libraries that would do it.
    Look for C++ Gui Libraries for linux (most of them are portable ).
    I've find out that if i want to use the mouse, then i gonna use XWarpPointer(). But i dono know more. It's works with Xlib.

    Somebody who can post a tiny code some i can work with?

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    I don't know anything about programming in Xlib ...

    but you should not try to tackle the native X library, unless you plan to do something which can't be done without it .

    What you want can easily be achieved with...say.. Qt ..
    See this Tutorial as an example..

    If you can't avoid X , read a documentation , examples are bound to be there.
    http://tronche.com/gui/x/xlib/input/
    Last edited by manasij7479; 07-09-2011 at 04:37 PM.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Sounds to me like you're trying to interact with a browser. And this seems like a very hack-ish way to do it. You would have to ensure that the resolution, window manager (and possibly window position) never change so the textbox always has the same position, etc.
    Most browsers I've seen usually offer some kind of IPC or plugin API which in my opinion would be both an easier and a "cleaner" way of doing it.
    Can you give us some more details on what it is you're trying to do?

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Quote Originally Posted by _Mike View Post
    Sounds to me like you're trying to interact with a browser. And this seems like a very hack-ish way to do it. You would have to ensure that the resolution, window manager (and possibly window position) never change so the textbox always has the same position, etc.
    Most browsers I've seen usually offer some kind of IPC or plugin API which in my opinion would be both an easier and a "cleaner" way of doing it.
    Can you give us some more details on what it is you're trying to do?
    I will use that program too mutch more.
    I think i will use QT, but to make this "functions" work, I don't know.

    First of all i want to do this.
    1. Move mouse
    2. Klick right and left
    3. Write with the mouse
    4. Paste text with the mouse.
    5. Recognize a chosen color. Like
    Code:
    "if (color == 747583){ do someting.} else{ pass}
    That is what im going to work with, in QT.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. X lib Mouse Click Error
    By lautarox in forum C Programming
    Replies: 8
    Last Post: 12-08-2008, 12:00 PM
  2. Using mouse click
    By kakashi in forum C++ Programming
    Replies: 10
    Last Post: 01-31-2006, 01:38 AM
  3. Move the cursor and click there
    By XunTric in forum Windows Programming
    Replies: 4
    Last Post: 12-21-2005, 10:03 PM
  4. Making a Mouse Click
    By r0ss in forum C Programming
    Replies: 1
    Last Post: 06-03-2004, 08:55 PM