I have tried two ways of doing it and both are not working: Win32::GuiTest and Win32::CtrlGUI.
Here is the second way, using Win32::CtrlGUI.use strict; use Win32::GuiTest qw(FindWindowLike GetChildWindows GetWindowText GetWindowID SetActiveWindow SetForegroundWindow PostMessage); sub WM_LBUTTONDOWN { 0x0201; } sub WM_LBUTTONUP { 0x0202; } my @winlst; my $tries = 0; while ($tries < 20) { print "trying to find the window\n"; @winlst = FindWindowLike(0,'StatusBar','TkTopLevel'); last if scalar(@winlst) > 0; $tries++; sleep 1; } if (@winlst == 1) { my $status = $winlst[0]; my $i; my $x = 30; my $y = 14; my $xy = ($y << 16) + $x; print "trying to send a click to the window\n"; SetForegroundWindow($status); SetActiveWindow($status); PostMessage($status, WM_LBUTTONDOWN, 0x0001, $xy); PostMessage($status, WM_LBUTTONUP, 0, $xy); }
In both cases Spy++ shows that the window is getting the button events, but it isn't responding. There are also some unusual messages in the log in both cases about a message 0x118:use strict; use Win32::CtrlGUI; my $win = Win32::CtrlGUI::wait_for_window("ParpadStatus"); my $x = 30; my $y = 14; my $xy = ($y << 16) + $x; print "trying to send a click to the window ", sprintf("0x%lx",$win->handle),"\n"; $win->post_message('NN', "WM_LBUTTONDOWN", 0x0001, $xy); $win->post_message('NN', "WM_LBUTTONUP", 0, $xy);
Does anyone have ideas about how I can get this to work, or if I should abandon it for better ways? I would rather not use sockets, because later I want to communicate asynchronously with other more complicated perl/Tk applications.003000BE R WM_ACTIVATE 003000BE P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:30 yPos:14 003000BE P WM_LBUTTONUP fwKeys:MK_LBUTTON xPos:30 yPos:14 003000BE P message:0x118 [Unknown] wParam:0000FFF8 lParam:A00885B9 003000BE S WM_NCACTIVATE fActive:False 003000BE R WM_NCACTIVATE fDeactivateOK:True
In reply to Simulating mouse clicks in Windows by tall_man
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |