- PushButton
Using the Keyboard
examples/Win32GUI/calc03.pl
# type in the calculation and see as the calculater reaches the result # use strict; use warnings; use Win32::GuiTest qw(:ALL); system "start calc.exe"; sleep(1); my $calculator_title = `$^X locale.pl --app calculator`; my @windows = FindWindowLike(undef, $calculator_title); print join ":", @windows, "\n"; if (not @windows) { die "Could not find Calculator\n"; } if (@windows > 1) { die "There might be more than one Calculators running\n"; } PushButton '7'; sleep(1); PushButton '\*'; sleep(1); PushButton '5'; sleep(1); PushButton '='; sleep(2); SendKeys("%{F4}"); # Alt-F4 to exit
Type in the calculation and see as the calculator reaches the result. Nice. It would be even better if after we typed in the values and pressed = we would be able to read the result automatically and then compare it to our expected value.