use strict; use warnings; use Win32::GuiTest qw( FindWindowLike GetChildWindows GetClassName GetWindowRect MouseMoveAbsPix SendMouse SetForegroundWindow ShowWindow ); use Getopt::Long; sub usage { print < USAGE exit 1; } my %opt = (wait => 0, set => undef); GetOptions(\%opt, "wait=i", "set=i" ) or usage(); usage() unless defined $opt{set}; usage() if $opt{set} < 0 || $opt{set} > 4; my $TMainForm; my $time = time + $opt{wait}; while (!$TMainForm) { my @windows = FindWindowLike(0, "Six Engine", "TMainForm"); if ( @windows ) { $TMainForm = $windows[0]; printf "TMainForm::%x\n", $TMainForm; last; } select(undef, undef, undef, 0.2); die "timeout\n" if $time + 1 < time; } my @children = GetChildWindows($TMainForm); my @buttons; for ( @children ) { next unless GetClassName($_) eq 'AsRadioButton'; push @buttons, $_; } die "can't find buttons" unless 5 == @buttons; ShowWindow($TMainForm, 1); SetForegroundWindow($TMainForm); sub click { my $window = shift; my ($x, $y) = GetWindowRect($window); MouseMoveAbsPix($x + 10, $y + 10); SendMouse('{LEFTDOWN}'); select(undef, undef, undef, 0.2); SendMouse('{LEFTUP}'); select(undef, undef, undef, 0.2); } # max, medium, high, turbo, auto click($buttons[$opt{set}]); print "$opt{set} set ok\n"; ShowWindow( $TMainForm, 0);