Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

jplindstrom
  (email not shown publicly)

Journal of jplindstrom (594)

Tuesday February 22, 2005
01:34 PM

MOTD: Win32::GuiTest

[ #23312 ]

Clicking on the same button again and again and again (you get the picture) until that bonus game is triggered?

Not me! Not with Win32::GuiTest in the toolbox.

#!/usr/bin/perl -w
use strict;
use Win32::GuiTest qw/ GetWindowText GetForegroundWindow SendMouse GetWindowRect ScreenToNorm /;
 
my ($titleWindow, $leftClick, $topClick) = @ARGV;
$titleWindow ||= "My App";
$leftClick ||= 750;
$topClick ||= 600;
 
while(1) {
    sleep(1);
 
    my $hwindTop = GetForegroundWindow() or next;
    GetWindowText($hwindTop)  =~ /\Q$titleWindow\E/ or warn("Window ($titleWindow) not active\n"), next;
 
    my ($left, $top) = GetWindowRect($hwindTop);
    $left += $leftClick;
    $top += $topClick;
    warn("Clicking on ($titleWindow) at $left, $top\n");
 
    ($left, $top) = ScreenToNorm($left, $top);
    SendMouse("{ABS$left,$top}{LEFTCLICK}");
}
 
__END__

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.