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.


In reply to Control+Mouse clicks to select items by AutomateWithPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.