Moving the mouse pointer on behalf of the user is commonly called "warping the pointer".

Have a look at the -warp portion of eventGenerate. Here's a short example that warps the pointer from a button down to a label when you click the button.

#!/usr/bin/perl use Tk; $m=Tk::MainWindow->new(); # create a button with a callback to do_warp $b=$m->Button(-text => "Press Me", -command => \&do_warp); # some filler labels so that the pointer warp is obvious $filler1=$m->Label(-text => " "); $filler2=$m->Label(-text => " "); # this label is where the mouse pointer ends up $l=$m->Label(-text => "Mouse ends up here"); $b->pack(); $filler1->pack(); $filler2->pack(); $l->pack(); MainLoop; sub do_warp { $l->eventGenerate('<ButtonPress>',-warp => 1); }
You could also play with the -x/-y options to place the pointer more specifically. Good luck.

Update: I should probably mention that moving the pointer around is generally considered "bad juju", and not the best UI design.


In reply to Re: Moving the mousepointer in Perl/Tk by kschwab
in thread Moving the mousepointer in Perl/Tk by Jouke

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.