#! C:/perl/bin/perl -w use strict; use Win32::API; use vars qw($rv); use constant BM_CLICK => hex('F5'); my $findwindow = new Win32::API("user32", "FindWindowA", ['P','P'], 'N'); my $findwindowex = new Win32::API("user32", "FindWindowExA", ['N','N','P','P'], 'N'); my $sendmessage = new Win32::API("user32", "SendMessageA", ['N','N','N','P'], 'N'); my $setactivewindow = new Win32::API("user32", "SetActiveWindow", ['N'], 'N'); # Find the handle of the parent window. In this case # 'Calculator' is the text shown in the title bar my $hwnd = $findwindow->Call( 0,'Calculator'); print "Parent window handle = $hwnd\n"; # Find the handle of the buttons we want to press. # Sometimes, but not always, the caption shown on the button my $hex_button = $findwindowex->Call($hwnd, 0, 0, 'Hex'); my $dec_button = $findwindowex->Call($hwnd, 0, 0, 'Dec'); my $oct_button = $findwindowex->Call($hwnd, 0, 0, 'Oct'); my $bin_button = $findwindowex->Call($hwnd, 0, 0, 'Bin'); $rv = $setactivewindow->Call($hwnd); print "setactivewindow returned = $rv\n"; foreach ($hex_button,$dec_button,$oct_button,$bin_button) { $rv = $sendmessage->Call($_ , BM_CLICK, 0, 0); print "sendmessage returned = $rv\n"; sleep 2; }