Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

controlling X's mouse pointer

by schweini (Friar)
on Oct 01, 2002 at 09:00 UTC ( #201950=perlquestion: print w/replies, xml ) Need Help??

schweini has asked for the wisdom of the Perl Monks concerning the following question:


is there any (easy) way to move the user's mouse pointer under X with perl?
i can't find any mentioning af actually controlling anything in the modules on CPAN...

Replies are listed 'Best First'.
Re: controlling X's mouse pointer
by JaWi (Hermit) on Oct 01, 2002 at 10:08 UTC
    I don't know wheter it can be directly done, but I assume you could look into X11::XEvent which provides you with an interface to send events to X11 directly. Yet I wonder why you possibly want to do this?

    Anyways, succes!

    -- JaWi

    "A chicken is an egg's way of producing more eggs."

      XEvent seems to be read-only...i tried WarpPointer from X11::Protocol, but couldn't get it to work :-(
      (which is probably my fault)

      i'm looking for something like this because i just had the dumbest idea of all times: make a "Minority Report"-like HID in perl! (I'd post it as a "cool use", if i could somehow get that darn pointer to move).
      it's actually quite simple (it's more a proof-of-concept thing than something actually usable), and controlling some LEDs with in-the-air-hand-movement (well...cigarette movement right now) simply feels groovy. (4 quadrants control the combination of LEDs connected to my parallel port that are supposed to light up)
      now all i need is a &putPointerToCoordinates(x,y) and a &clickAtCurrentCoordinates()....but how?
      (i'm a c-analphabetic, BTW)

      (update: fixed spelling. ain't caffeine great?)
Re: controlling X's mouse pointer
by Jouke (Curate) on Oct 02, 2002 at 08:24 UTC
    Well, if you have a Tk application for example and you want to move the mousepointer in any of the windows you have defined you are able to Warp the mousepointer.

    AFAIK there is no way in Perl to move the mousepointer in X if it has nothing to do with your self-defined application.


    Jouke Visser, Perl 'Adept'
    Using Perl to help the disabled: pVoice and pStory

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://201950]
Approved by valdez
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2020-02-26 14:30 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (117 votes). Check out past polls.