Results 1 to 4 of 4

Thread: Global Mouse / Keyboard Hook

  1. #1
    Join Date
    Sep 2008
    Beans
    3

    Global Mouse / Keyboard Hook

    Is there a way using C, C++ java python or any other language to get a hook on the mouse and keyboard event under linux GNOME or KDE where I can detect if thre hasn't been any motion or keys pressend in a while? Even if my application doesn't have the focus?


    Thanks

  2. #2
    Join Date
    Apr 2009
    Beans
    7

    Re: Global Mouse / Keyboard Hook

    Wow, sorry to piggyback your thread but I was about to ask exactly the same question. Any ideas would be gratefully recieved

  3. #3
    Join Date
    Apr 2009
    Beans
    7

    Re: Global Mouse / Keyboard Hook

    This is a bit rough and quick, but here is a basic python-xlib script I came up to show my most successful attempt to date.

    It picks up a single button click and tells you its x, y coordinates .



    from Xlib import X, display

    trip = False

    while trip == False:
    d = display.Display().screen().root.query_pointer()._d ata

    #In my case Left down = 256, right down = 1024 and no press = 0
    if d["mask"] == 256:
    print "Left Down"
    print "xpos: " + str(d["root_x"]) + " | ypos: " + str(d["root_y"])
    trip = True
    elif d["mask"] == 1024:
    print "Right Down"
    print "xpos: " + str(d["root_x"]) + " | ypos: " + str(d["root_y"])
    trip = True

  4. #4
    Join Date
    Feb 2007
    Beans
    521
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Global Mouse / Keyboard Hook

    You could take a look at the unclutter program. It hides the mouse cursor when it is unmoved for some time.
    make install - not war!

    Oh hai!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •