anyone know how to simulate a mouse click? 
Author Message
 anyone know how to simulate a mouse click?
Hello,

        Does anyone know of a way to simulate a mouse click with a perl
program, for instance a script that, once run, connects to
http://www.*-*-*.com/
and clicks at x=340 y=190 ?  Any help would be appreciated.



Tue, 24 Jun 2003 04:00:05 GMT  
 anyone know how to simulate a mouse click?

Quote:

> Hello,

>         Does anyone know of a way to simulate a mouse click with a perl
> program, for instance a script that, once run, connects to
> http://www.mypage.com/
> and clicks at x=340 y=190 ?  Any help would be appreciated.

Maybe you can be somewhat more specific?
Paul


Tue, 24 Jun 2003 04:53:52 GMT  
 anyone know how to simulate a mouse click?

Quote:

> Hello,
>         Does anyone know of a way to simulate a mouse click with a perl
> program, for instance a script that, once run, connects to
> http://www.mypage.com/
> and clicks at x=340 y=190 ?  Any help would be appreciated.

You don't really want the program to simulate a mouse click.
What you want is for the program to act as a client, and for
it to do what a browser would do to tell the server where a
mouse click was supposedly made. There are two types of image
maps.

The best place to look for HTML specs is http://www.w3.org
which is the home page of the Worled Wide Web Consortium, or
W3C for short.

This really is not a Perl issue, it is an HTML client issue.
Read the HTML specs. I'll go ahead and include part of the
HTML 4.01 spec concerning image maps if you promise to read
the rest yourself.

An image map is created by associating an object with a specification of sensitive geometric areas on the object.

<part of the image map spec>
    There are two types of image maps:

    Client-side.
    When a user activates a region of a client-side image map
    with a mouse, the pixel coordinates are interpreted by the
    user agent. The user agent selects a link that was specified
    for the activated region and follows it.

    Server-side.
    When a user activates a region of a server-side image map
    with a mouse, the pixel coordinates of the click are sent
    to the server-side agent specified by the href attribute
    of the A element. The server-side agent interprets the
    coordinates and performs some action.

    Client-side image maps are preferred over server-side image
    maps for at least two reasons: they are accessible to people
    browsing with non-graphical user agents and they offer
    immediate feedback as to whether or not the pointer is over
    an active region.
</part of the image map spec>

The above and much more can be found at:
http://www.w3.org/TR/html4/struct/objects.html#h-13.6

Please go to a web-related newsgroup with further questions.

Chris

--
Christopher E. Stith

Product shown enlarged to make you think you're getting more.



Tue, 24 Jun 2003 05:05:22 GMT  
 anyone know how to simulate a mouse click?
Ok, let's say I write something like this:

#!/usr/bin/perl -w
use strict;
use LWP::Simple qw(get);
my $url = "http://www.foo.com/";
my $page = get $url or die "hi: $!\n";
print "Content-type: text/html\n\n";
print "$page";
let's assume this page has a submit button.  Can I simulate a mouse click so
that the button is pushed, thus sending info to the cgi script that handles
the form input?

    Alternatively, if the above is not possible, can I connect to a web site
via a socket and have some predefined areas to click, such that I could run
the script and make it through an entire set of forms?  A statement like: my
$next_page = get->Mouse::Click(480, 135) would be one example, which would
allow $next_page to contain the html yielded from the page after clicking the
submit button.

Any help would be appreciated.

Quote:


> > Hello,

> >         Does anyone know of a way to simulate a mouse click with a perl
> > program, for instance a script that, once run, connects to
> > http://www.mypage.com/
> > and clicks at x=340 y=190 ?  Any help would be appreciated.

> Maybe you can be somewhat more specific?
> Paul



Tue, 24 Jun 2003 05:16:56 GMT  
 anyone know how to simulate a mouse click?

[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote an entire article.

  Jeopardectomy performed.
]

Quote:



>> >         Does anyone know of a way to simulate a mouse click with a perl
>> > program,

You can do GUI stuff with the Tk module.

Quote:
>for instance a script that, once run, connects to
>> > http://www.mypage.com/
>> > and clicks at x=340 y=190 ?  Any help would be appreciated.

Oh. You don't mean just a Perl program, you mean a Perl program
running in a CGI environment. Not at all the same thing.

Quote:
>> Maybe you can be somewhat more specific?
>Ok, let's say I write something like this:

[ snip very fine code with warnings and strictures ]

Quote:
>let's assume this page has a submit button.  

So then it has a <form> tag. Examine it to see what it does.
What HTML thingies mean is off-topic in a Perl newsgroup.

Quote:
>Can I simulate a mouse click so
>that the button is pushed, thus sending info to the cgi script that handles
>the form input?

Oh, I see now what you want.

No. What you do is write a Perl program that does what the browser
does when you "click" (so that you don't have to click).

When you click on "submit" something happens. What the something
is is specific to the application area that you are applying
Perl to, not to Perl.

So it should not be here in the Perl newsgroup. Luckily there
is a newsgroup where such things are discussed:

         comp.infosystems.www.authoring.cgi

Find out what the interface requires, then code it up in Perl.

Quote:
>Any help would be appreciated.

   use LWP::UserAgent;  # to submit a "filled out" form

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Tue, 24 Jun 2003 08:42:29 GMT  
 anyone know how to simulate a mouse click?

Quote:

> Ok, let's say I write something like this:

> #!/usr/bin/perl -w
> use strict;
> use LWP::Simple qw(get);
> my $url = "http://www.foo.com/";
> my $page = get $url or die "hi: $!\n";
> print "Content-type: text/html\n\n";
> print "$page";
> let's assume this page has a submit button.  Can I simulate a mouse click so
> that the button is pushed, thus sending info to the cgi script that handles
> the form input?

I think that the HTML::Form module should do what you like.  Just try
to append lines like the following to your script:

require HTML::Form;
my $form = HTML::Form->parse($page, $url);
my $req = $form->click(480, 135);

# $req is a HTTP::Request object, so you have to use OO LWP after this
$ua = LWP::UserAgent->new;
my $res = $ua->request($req);
print $res->as_string;

--
Gisle Aas



Tue, 24 Jun 2003 12:56:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. simulating a mouse click?

2. Simulating mouse clicks on other GUI programs

3. HList bug (single click simulates 2 clicks?)

4. Sending keystrokes and mouse click under WinPerl

5. Mouse click location on a scrolled canvas

6. Mouse Click Bind for an Entry Widget

7. binding mouse clicks to Tk::Columns

8. left mouse click on HList throws messages when empty

9. A weird one - misguided mouse clicks and all that

10. mouse right click

11. Please help: Binding mouse click to tree entry.

12. binding right mouse button click to all buttons

 

 
Powered by phpBB® Forum Software