Loading ...
Sorry, an error occurred while loading the content.

Re: Using SendKeys- Simulate or Double mouse Click

Expand Messages
  • markmontemuro
    ... I ve ... components ... ... text ... the ... Here is a simple program which shows the problem. When the highlight button is selected, the
    Message 1 of 12 , Nov 7, 2005
    • 0 Attachment
      --- In perlguitest@yahoogroups.com, "rmqa_group" <rmqa_group@y...>
      wrote:
      >
      > Try:
      >
      > SendKeys("{HOME}+({END}){DELETE}");
      >
      > I'm not sure the braces around {END} are strictly necessary, but
      I've
      > run into problems with SendKeys seemingly not releasing a modifier
      > key if the braces aren't used. Alternatively, separate the
      components
      > out into three SendKeys calls...
      >
      > DH
      >
      >
      > --- In perlguitest@yahoogroups.com, "markmontemuro" <montemur@s...>
      > wrote:
      > >
      > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski"
      <pkaluski@p...>
      > > wrote:
      > > >
      > > > In order to emulate Shift, you have to use '+' (rather then
      > > {SHIFT}).
      > > >
      > > > --Piotr
      > > >
      > > > --- In perlguitest@yahoogroups.com, "markmontemuro"
      > <montemur@s...>
      > > wrote:
      > > > >
      > > > > I'm trying to simulate using SendKeys to highlight text on an
      > > entry
      > > > > box. I use SendKeys("{HOME"); to mark the beginning of the
      text
      > > and
      > > > > then I tried SendKeys("{SHIFT}{END}"); to highlight the text
      > and
      > > only
      > > > > the END action seems to happen. I also tried
      > > > > SendKeys("{HOME}{SHIFT}{END}{DELETE}"); The curser moved from
      > > beginning
      > > > > to end, but the text is not highlighted.
      > > > >
      > > > > Any suggestions?
      > > > >
      > > > >
      > > > > I am also trying to simulate a double mouse click. Any
      > > suggestions?
      > > > >
      > > >
      > > What would your syntax be? I still can't get this to work with
      the
      > +.
      > > This is actually updating a perl TK Entry field. I can use the
      > HOME,
      > > SHIFT HOME key sequence from the keyboard, so I'm hoping I can do
      > > this from GUITEST.
      > >
      >

      Here is a simple program which shows the problem. When the highlight
      button is selected, the curser just goes to the end of the text. The
      text is not highlighted. Any suggestions?

      use Tk;
      use Win32::GuiTest qw(SendKeys );

      my $mw = MainWindow->new;

      my $e = $mw->Entry->pack;
      $e->insert(0, "Test String");

      my $f = $mw->Frame->pack;

      $f->Button(
      -text => "Highlight",
      -command => [\&highlight, $e]
      )->pack(-side => 'left');

      MainLoop;

      sub highlight
      {
      my $e = shift;
      $e->focusForce;
      SendKeys("{HOME}+({END}) {DELETE}");
      }
    • rmqa_group
      Hmmm, strange. The + (shift) modifier doesn t seem to work with either {HOME} or {END}. I ve not had need to use it in this combination, though +{TAB} seems
      Message 2 of 12 , Nov 9, 2005
      • 0 Attachment
        Hmmm, strange.

        The "+" (shift) modifier doesn't seem to work with either {HOME} or
        {END}. I've not had need to use it in this combination, though +{TAB}
        seems to work as expected.

        It also seems to "jam" the shift key, as switching to another
        application after the script, you may find the shift still engaged.

        You may have to resort to using the SendRawKey function instead...

        DH

        > Here is a simple program which shows the problem. When the
        highlight
        > button is selected, the curser just goes to the end of the text.
        The
        > text is not highlighted. Any suggestions?
        >
        > use Tk;
        > use Win32::GuiTest qw(SendKeys );
        >
        > my $mw = MainWindow->new;
        >
        > my $e = $mw->Entry->pack;
        > $e->insert(0, "Test String");
        >
        > my $f = $mw->Frame->pack;
        >
        > $f->Button(
        > -text => "Highlight",
        > -command => [\&highlight, $e]
        > )->pack(-side => 'left');
        >
        > MainLoop;
        >
        > sub highlight
        > {
        > my $e = shift;
        > $e->focusForce;
        > SendKeys("{HOME}+({END}) {DELETE}");
        > }
        >
      • Abhishek Singh
        Hi Guys Is there any method through which we can schedule a service (that can be restarted in every 30 minutes) running on Wndows 2000 Professional. Regards
        Message 3 of 12 , Nov 14, 2005
        • 0 Attachment
          Hi Guys



          Is there any method through which we can schedule a service (that can be restarted in every 30 minutes) running on Wndows 2000 Professional.



          Regards

          Abhishek


          ---------------------------------
          Yahoo! FareChase - Search multiple travel sites in one click.

          [Non-text portions of this message have been removed]
        • tobin_cataldo
          Has anybody found a solution to this without using SendRawKey? SendKeys( +({DOWN 100}) ); and{PGDN} jam the shift as well, without actually highlighting.
          Message 4 of 12 , Jun 9, 2006
          • 0 Attachment
            Has anybody found a solution to this without using SendRawKey?

            SendKeys("+({DOWN 100})");
            and{PGDN} jam the shift as well, without actually highlighting.

            --- In perlguitest@yahoogroups.com, "rmqa_group" <rmqa_group@...> wrote:
            >
            > Hmmm, strange.
            >
            > The "+" (shift) modifier doesn't seem to work with either {HOME} or
            > {END}. I've not had need to use it in this combination, though +{TAB}
            > seems to work as expected.
            >
            > It also seems to "jam" the shift key, as switching to another
            > application after the script, you may find the shift still engaged.
            >
            > You may have to resort to using the SendRawKey function instead...
            >
            > DH
            >
            > > Here is a simple program which shows the problem. When the
            > highlight
            > > button is selected, the curser just goes to the end of the text.
            > The
            > > text is not highlighted. Any suggestions?
            > >
            > > use Tk;
            > > use Win32::GuiTest qw(SendKeys );
            > >
            > > my $mw = MainWindow->new;
            > >
            > > my $e = $mw->Entry->pack;
            > > $e->insert(0, "Test String");
            > >
            > > my $f = $mw->Frame->pack;
            > >
            > > $f->Button(
            > > -text => "Highlight",
            > > -command => [\&highlight, $e]
            > > )->pack(-side => 'left');
            > >
            > > MainLoop;
            > >
            > > sub highlight
            > > {
            > > my $e = shift;
            > > $e->focusForce;
            > > SendKeys("{HOME}+({END}) {DELETE}");
            > > }
            > >
            >
          • brentje
            I think I have an explaination at least... Been checking out the GuiTest.XS code, since I m having a problem sending brackets through SendKeys. Appearently
            Message 5 of 12 , Jun 28, 2006
            • 0 Attachment
              I think I have an explaination at least...

              Been checking out the GuiTest.XS code, since I'm having a problem
              sending brackets through SendKeys. Appearently there are 2 more
              modifiers that aren't documented: the ( and the ). They are used as a
              pseudo shiftlock. The + modifier only works for the very next
              character after it, and the shift key is released after that character
              is processed. Now you would hope that either using

              SendKeys("{HOME}+{END}{DELETE}")

              on a text field would do what you want...highlight all the text in a
              text field and delete it. You would also hope that if that didn't
              work, that

              SendKeys("{HOME}({END}){DELETE}")

              would work. BUT...whenever the SendKeysImp function in the
              GuiTest.XS, the function called my SendKeys, processes a { character,
              the Shift flag for either the + or ( modifiers gets reset and turned
              off. So it's technically impossible to have it hold down the Shift
              and any special keys at the same time using SendKeys.

              As for it jamming the Shift key to be always on...still haven't
              figured that out. It seems to happen whenever the ( and ) modifiers
              are used as well. The Shift just doesn't disengage. I haven't had it
              happen to me with the + modifier, and haven't tried the {SHIFT}
              special key, but it definately happens with ( and ).

              OH, and if you were like me and wondered how exactly you send the
              literal characters instead of the modifier, just put it in squigly
              braces {}. As in:

              SendKeys("{(}This is in brackets{)}");

              That should produce:

              (This is in brackets)

              So...I think you might be out of luck unfortunately. The only way
              I've been able to do it is with the mouse.
              Here's my function:

              sub ClearEditControl
              {
              my $H_Control = shift;

              my $i_Y = 0;
              my $i_LeftX = 0;
              my $i_TopY = 0;
              my $i_RightX = 0;
              my $i_BottomY = 0;


              ($i_LeftX, $i_TopY, $i_RightX, $i_BottomY) = GetWindowRect(
              $H_Control );

              $i_Y = $i_TopY + (int(($i_BottomY - $i_TopY)/2));

              tt_MoveMouse($i_LeftX, $i_Y);

              SendLButtonDown();

              tt_MoveMouse($i_RightX, $i_Y);

              SendLButtonUp();

              SendKeys("{DELETE}");

              }

              Good luck, and post your workaround if you find another one...

              Brent


              --- In perlguitest@yahoogroups.com, "tobin_cataldo" <tcataldo@...> wrote:
              >
              > Has anybody found a solution to this without using SendRawKey?
              >
              > SendKeys("+({DOWN 100})");
              > and{PGDN} jam the shift as well, without actually highlighting.
              >
              > --- In perlguitest@yahoogroups.com, "rmqa_group" <rmqa_group@> wrote:
              > >
              > > Hmmm, strange.
              > >
              > > The "+" (shift) modifier doesn't seem to work with either {HOME} or
              > > {END}. I've not had need to use it in this combination, though +{TAB}
              > > seems to work as expected.
              > >
              > > It also seems to "jam" the shift key, as switching to another
              > > application after the script, you may find the shift still engaged.
              > >
              > > You may have to resort to using the SendRawKey function instead...
              > >
              > > DH
              > >
              > > > Here is a simple program which shows the problem. When the
              > > highlight
              > > > button is selected, the curser just goes to the end of the text.
              > > The
              > > > text is not highlighted. Any suggestions?
              > > >
              > > > use Tk;
              > > > use Win32::GuiTest qw(SendKeys );
              > > >
              > > > my $mw = MainWindow->new;
              > > >
              > > > my $e = $mw->Entry->pack;
              > > > $e->insert(0, "Test String");
              > > >
              > > > my $f = $mw->Frame->pack;
              > > >
              > > > $f->Button(
              > > > -text => "Highlight",
              > > > -command => [\&highlight, $e]
              > > > )->pack(-side => 'left');
              > > >
              > > > MainLoop;
              > > >
              > > > sub highlight
              > > > {
              > > > my $e = shift;
              > > > $e->focusForce;
              > > > SendKeys("{HOME}+({END}) {DELETE}");
              > > > }
              > > >
              > >
              >
            • Piotr Kaluski
              Hi, I have carefully checked what you have written. I have also run the script using Tk, attached below. Everything worked as expected. Below is the script,
              Message 6 of 12 , Oct 14, 2006
              • 0 Attachment
                Hi,
                I have carefully checked what you have written. I have also run the
                script using Tk, attached below. Everything worked as expected.
                Below is the script, which uses Notepad.

                use Win32::GuiTest qw( :ALL );
                my @wnd = FindWindowLike( 0, "Untitled - Notepad" );

                SetForegroundWindow( $wnd[ 0 ] );
                SendKeys( "{HOME}" );
                sleep( 1 );
                SendKeys( "+{END}" );
                sleep( 1 );
                SendKeys( "{DELETE}" );
                print "\n";

                It does exactly what is expected. It goes to beginning of the line, it
                selects the whole line and then deletes it.

                In order to get a shift pressed, you have to use +. If you want it to
                be kept for more then one character, you take all to-be-shifted
                characters in parens "()". "()" by themself only group characters. I
                did not observe them working as a shift key.

                And what do you mean by jaming? How does it manifest itself?
                What windows version do you use?

                --Piotr


                --- In perlguitest@yahoogroups.com, "brentje" <brentje@...> wrote:
                >
                > I think I have an explaination at least...
                >
                > Been checking out the GuiTest.XS code, since I'm having a problem
                > sending brackets through SendKeys. Appearently there are 2 more
                > modifiers that aren't documented: the ( and the ). They are used as a
                > pseudo shiftlock. The + modifier only works for the very next
                > character after it, and the shift key is released after that character
                > is processed. Now you would hope that either using
                >
                > SendKeys("{HOME}+{END}{DELETE}")
                >
                > on a text field would do what you want...highlight all the text in a
                > text field and delete it. You would also hope that if that didn't
                > work, that
                >
                > SendKeys("{HOME}({END}){DELETE}")
                >
                > would work. BUT...whenever the SendKeysImp function in the
                > GuiTest.XS, the function called my SendKeys, processes a { character,
                > the Shift flag for either the + or ( modifiers gets reset and turned
                > off. So it's technically impossible to have it hold down the Shift
                > and any special keys at the same time using SendKeys.
                >
                > As for it jamming the Shift key to be always on...still haven't
                > figured that out. It seems to happen whenever the ( and ) modifiers
                > are used as well. The Shift just doesn't disengage. I haven't had it
                > happen to me with the + modifier, and haven't tried the {SHIFT}
                > special key, but it definately happens with ( and ).
                >
                > OH, and if you were like me and wondered how exactly you send the
                > literal characters instead of the modifier, just put it in squigly
                > braces {}. As in:
                >
                > SendKeys("{(}This is in brackets{)}");
                >
                > That should produce:
                >
                > (This is in brackets)
                >
                > So...I think you might be out of luck unfortunately. The only way
                > I've been able to do it is with the mouse.
                > Here's my function:
                >
                > sub ClearEditControl
                > {
                > my $H_Control = shift;
                >
                > my $i_Y = 0;
                > my $i_LeftX = 0;
                > my $i_TopY = 0;
                > my $i_RightX = 0;
                > my $i_BottomY = 0;
                >
                >
                > ($i_LeftX, $i_TopY, $i_RightX, $i_BottomY) = GetWindowRect(
                > $H_Control );
                >
                > $i_Y = $i_TopY + (int(($i_BottomY - $i_TopY)/2));
                >
                > tt_MoveMouse($i_LeftX, $i_Y);
                >
                > SendLButtonDown();
                >
                > tt_MoveMouse($i_RightX, $i_Y);
                >
                > SendLButtonUp();
                >
                > SendKeys("{DELETE}");
                >
                > }
                >
                > Good luck, and post your workaround if you find another one...
                >
                > Brent
                >
                >
                > --- In perlguitest@yahoogroups.com, "tobin_cataldo" <tcataldo@> wrote:
                > >
                > > Has anybody found a solution to this without using SendRawKey?
                > >
                > > SendKeys("+({DOWN 100})");
                > > and{PGDN} jam the shift as well, without actually highlighting.
                > >
                > > --- In perlguitest@yahoogroups.com, "rmqa_group" <rmqa_group@> wrote:
                > > >
                > > > Hmmm, strange.
                > > >
                > > > The "+" (shift) modifier doesn't seem to work with either {HOME} or
                > > > {END}. I've not had need to use it in this combination, though
                +{TAB}
                > > > seems to work as expected.
                > > >
                > > > It also seems to "jam" the shift key, as switching to another
                > > > application after the script, you may find the shift still engaged.
                > > >
                > > > You may have to resort to using the SendRawKey function instead...
                > > >
                > > > DH
                > > >
                > > > > Here is a simple program which shows the problem. When the
                > > > highlight
                > > > > button is selected, the curser just goes to the end of the text.
                > > > The
                > > > > text is not highlighted. Any suggestions?
                > > > >
                > > > > use Tk;
                > > > > use Win32::GuiTest qw(SendKeys );
                > > > >
                > > > > my $mw = MainWindow->new;
                > > > >
                > > > > my $e = $mw->Entry->pack;
                > > > > $e->insert(0, "Test String");
                > > > >
                > > > > my $f = $mw->Frame->pack;
                > > > >
                > > > > $f->Button(
                > > > > -text => "Highlight",
                > > > > -command => [\&highlight, $e]
                > > > > )->pack(-side => 'left');
                > > > >
                > > > > MainLoop;
                > > > >
                > > > > sub highlight
                > > > > {
                > > > > my $e = shift;
                > > > > $e->focusForce;
                > > > > SendKeys("{HOME}+({END}) {DELETE}");
                > > > > }
                > > > >
                > > >
                > >
                >
              • Piotr Kaluski
                OK. I have the same problem. I got it on a machine with Polish version of XP. And in the same time it works fine on a machine with US XP. More investigation is
                Message 7 of 12 , Feb 20, 2007
                • 0 Attachment
                  OK. I have the same problem. I got it on a machine with Polish version
                  of XP. And in the same time it works fine on a machine with US XP.

                  More investigation is needed. But for sure there is a problem...

                  --Piotr

                  --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@...> wrote:
                  >
                  > Hi,
                  > I have carefully checked what you have written. I have also run the
                  > script using Tk, attached below. Everything worked as expected.
                  > Below is the script, which uses Notepad.
                  >
                  > use Win32::GuiTest qw( :ALL );
                  > my @wnd = FindWindowLike( 0, "Untitled - Notepad" );
                  >
                  > SetForegroundWindow( $wnd[ 0 ] );
                  > SendKeys( "{HOME}" );
                  > sleep( 1 );
                  > SendKeys( "+{END}" );
                  > sleep( 1 );
                  > SendKeys( "{DELETE}" );
                  > print "\n";
                  >
                  > It does exactly what is expected. It goes to beginning of the line, it
                  > selects the whole line and then deletes it.
                  >
                  > In order to get a shift pressed, you have to use +. If you want it to
                  > be kept for more then one character, you take all to-be-shifted
                  > characters in parens "()". "()" by themself only group characters. I
                  > did not observe them working as a shift key.
                  >
                  > And what do you mean by jaming? How does it manifest itself?
                  > What windows version do you use?
                  >
                  > --Piotr
                  >
                  >
                  > --- In perlguitest@yahoogroups.com, "brentje" <brentje@> wrote:
                  > >
                  > > I think I have an explaination at least...
                  > >
                  > > Been checking out the GuiTest.XS code, since I'm having a problem
                  > > sending brackets through SendKeys. Appearently there are 2 more
                  > > modifiers that aren't documented: the ( and the ). They are used as a
                  > > pseudo shiftlock. The + modifier only works for the very next
                  > > character after it, and the shift key is released after that character
                  > > is processed. Now you would hope that either using
                  > >
                  > > SendKeys("{HOME}+{END}{DELETE}")
                  > >
                  > > on a text field would do what you want...highlight all the text in a
                  > > text field and delete it. You would also hope that if that didn't
                  > > work, that
                  > >
                  > > SendKeys("{HOME}({END}){DELETE}")
                  > >
                  > > would work. BUT...whenever the SendKeysImp function in the
                  > > GuiTest.XS, the function called my SendKeys, processes a { character,
                  > > the Shift flag for either the + or ( modifiers gets reset and turned
                  > > off. So it's technically impossible to have it hold down the Shift
                  > > and any special keys at the same time using SendKeys.
                  > >
                  > > As for it jamming the Shift key to be always on...still haven't
                  > > figured that out. It seems to happen whenever the ( and ) modifiers
                  > > are used as well. The Shift just doesn't disengage. I haven't had it
                  > > happen to me with the + modifier, and haven't tried the {SHIFT}
                  > > special key, but it definately happens with ( and ).
                  > >
                  > > OH, and if you were like me and wondered how exactly you send the
                  > > literal characters instead of the modifier, just put it in squigly
                  > > braces {}. As in:
                  > >
                  > > SendKeys("{(}This is in brackets{)}");
                  > >
                  > > That should produce:
                  > >
                  > > (This is in brackets)
                  > >
                  > > So...I think you might be out of luck unfortunately. The only way
                  > > I've been able to do it is with the mouse.
                  > > Here's my function:
                  > >
                  > > sub ClearEditControl
                  > > {
                  > > my $H_Control = shift;
                  > >
                  > > my $i_Y = 0;
                  > > my $i_LeftX = 0;
                  > > my $i_TopY = 0;
                  > > my $i_RightX = 0;
                  > > my $i_BottomY = 0;
                  > >
                  > >
                  > > ($i_LeftX, $i_TopY, $i_RightX, $i_BottomY) = GetWindowRect(
                  > > $H_Control );
                  > >
                  > > $i_Y = $i_TopY + (int(($i_BottomY - $i_TopY)/2));
                  > >
                  > > tt_MoveMouse($i_LeftX, $i_Y);
                  > >
                  > > SendLButtonDown();
                  > >
                  > > tt_MoveMouse($i_RightX, $i_Y);
                  > >
                  > > SendLButtonUp();
                  > >
                  > > SendKeys("{DELETE}");
                  > >
                  > > }
                  > >
                  > > Good luck, and post your workaround if you find another one...
                  > >
                  > > Brent
                  > >
                  > >
                  > > --- In perlguitest@yahoogroups.com, "tobin_cataldo" <tcataldo@> wrote:
                  > > >
                  > > > Has anybody found a solution to this without using SendRawKey?
                  > > >
                  > > > SendKeys("+({DOWN 100})");
                  > > > and{PGDN} jam the shift as well, without actually highlighting.
                  > > >
                  > > > --- In perlguitest@yahoogroups.com, "rmqa_group" <rmqa_group@>
                  wrote:
                  > > > >
                  > > > > Hmmm, strange.
                  > > > >
                  > > > > The "+" (shift) modifier doesn't seem to work with either
                  {HOME} or
                  > > > > {END}. I've not had need to use it in this combination, though
                  > +{TAB}
                  > > > > seems to work as expected.
                  > > > >
                  > > > > It also seems to "jam" the shift key, as switching to another
                  > > > > application after the script, you may find the shift still
                  engaged.
                  > > > >
                  > > > > You may have to resort to using the SendRawKey function instead...
                  > > > >
                  > > > > DH
                  > > > >
                  > > > > > Here is a simple program which shows the problem. When the
                  > > > > highlight
                  > > > > > button is selected, the curser just goes to the end of the
                  text.
                  > > > > The
                  > > > > > text is not highlighted. Any suggestions?
                  > > > > >
                  > > > > > use Tk;
                  > > > > > use Win32::GuiTest qw(SendKeys );
                  > > > > >
                  > > > > > my $mw = MainWindow->new;
                  > > > > >
                  > > > > > my $e = $mw->Entry->pack;
                  > > > > > $e->insert(0, "Test String");
                  > > > > >
                  > > > > > my $f = $mw->Frame->pack;
                  > > > > >
                  > > > > > $f->Button(
                  > > > > > -text => "Highlight",
                  > > > > > -command => [\&highlight, $e]
                  > > > > > )->pack(-side => 'left');
                  > > > > >
                  > > > > > MainLoop;
                  > > > > >
                  > > > > > sub highlight
                  > > > > > {
                  > > > > > my $e = shift;
                  > > > > > $e->focusForce;
                  > > > > > SendKeys("{HOME}+({END}) {DELETE}");
                  > > > > > }
                  > > > > >
                  > > > >
                  > > >
                  > >
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.