AutomateWithPerl has asked for the wisdom of the Perl Monks concerning the following question:
We are all familiar with using the CNTRL button and mouse clicks to select multiple items in a list box. Especially good for non-contiguous selections.
I ran into problems recently trying to automate this very series of actions with Perl. I use Win32:GuiTest and similar modules to automate proprietary company software.
Problems:
- You cannot use SendKeys() and mouse controls like SendMouse() at the same time.
- You cannot use SendKeys() to "hold down" the Control key while you do other things.
The solution was to have my test script call another script, which will "hold down" the Control key while doing the click at the same time:
system 1, ".\\HoldControlKey.pl"; sleep 4; &SingleClick( 200, 245 ); sleep 7;
The system call will run the other script and continue execution of the calling script. Here is the code from HoldControlKey.pl:
use Win32::GuiTest qw(:ALL :SW ); sleep 2; SendKeys( "^(1111111111)", 500 );
The trick here is to press Control-1 repeatedly (which does nothing to the display), with a 1/2 second between each press of '1', but the Control key is held down. I had to adjust the 'sleep's to get the timing just right, but the solution worked.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Control+Mouse clicks to select items
by BrowserUk (Patriarch) on Mar 15, 2011 at 05:05 UTC | |
|
Re: Control+Mouse clicks to select items
by Anonymous Monk on Mar 15, 2011 at 07:35 UTC |