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

Re: Sending Text to a textbox does not work

Expand Messages
  • Dennis K. Paulsen
    A couple of thoughts on this: * Your application may be taking more then 3 seconds to load up, display applicable windows, and become ready for keyboard input,
    Message 1 of 7 , Jul 3 5:17 PM
    • 0 Attachment
      A couple of thoughts on this:

      * Your application may be taking more then 3 seconds to load up,
      display applicable windows, and become ready for keyboard input, so
      try using WaitWindow in place of any sleep statement. Note: Notepad
      may be working with it because it is loading up in under 3 seconds
      and is ready to accept the input.

      * Double-check the parameters you are currently using for
      WaitWindowLike, because a value of 60 for the window class is
      incorrect. You may wish to use the simpler WaitWindow function
      instead: WaitWindow(TITLERX, WAIT); which makes it easier.

      * WaitWindowLike returns the first window found matching the search
      criteria, so you could use that value instead of calling
      FindWindowLike too. However, if you're also wanting to see your
      primary window's children, then you could use FindWindowLike and
      specify the value previously discussed as the window to start
      under. Outlined in the example below.

      * Also, if you want to press <Enter> using SendKeys, use '~'
      or '{ENTER}' in place of "\n"; which is actually just for CRLF.


      The following !untested! partial example (based off your code)
      includes these thoughts:

      my $title = "Powersafe Actions Configuration";

      system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
      my $window = WaitWindow($title, 60);
      if (not $window) {
      die("Window not found!: $title");
      }

      # Window is loaded up, so it should be ready for input
      SendKeys("admin~"); # Send string and an <Enter>

      # Now show children (text boxes, etc.) of $window
      foreach my $child ( FindWindowLike($window) ) {
      # Show Window Ids and any readily available text (for labels,
      # text boxes, etc.)
      print sprintf("Window Id: 0x%08X Window Text: '%s'\n",
      $child, WMGetText($child));
      }


      Regards,
      Dennis K. Paulsen

      > > --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...>
      > wrote:
      > > > Hi,
      > > >
      > > > I am new to this forum. I am unable to figure out why I cant
      seem
      > > to
      > > > send input to the textbox in my Application. My code:
      > > >
      > > > use Win32::GuiTest qw/GetChildWindows WMSetText WMGetText
      > > > WaitWindowLike IsWindowEnabled PushButton SendKeys
      FindWindowLike
      > > > GetWindowText
      > > > GetClassName GetChildDepth GetDesktopWindow
      > SetForegroundWindow/;
      > > >
      > > >
      > > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
      > > > sleep 3;
      > > >
      > > > SendKeys("admin\n");
      > > >
      > > > $title = "Powersafe Actions Configuration"; # title of window
      to
      > > > search for
      > > > WaitWindowLike(0, $title, 60);
      > > > @mywindow = FindWindowLike(0, $title);
      > > > foreach(@mywindow){print "Window ". sprintf "%lx\n",$_;}
      > > >
      > > > My application does open with the focus set on the first
      textbox,
      > > but
      > > > neither do the keys get sent, nor does anything get printed.
      > > >
      > > > Please help,
      > > >
      > > > Regards,
      > > > -skanitkar
    • shsk7203
      Thanks a bunch. Wonderful information. After a few debug tricks I just realised that the problem lies elsewhere. Once my Powersafe App loads, it s like the app
      Message 2 of 7 , Jul 3 10:59 PM
      • 0 Attachment
        Thanks a bunch. Wonderful information.

        After a few debug tricks I just realised that the problem lies
        elsewhere. Once my Powersafe App loads, it's like the app has taken
        over. I put in a simple print("Am I printing") before and after the
        system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
        and the print after does not get printed. also, the perl shell also
        stays alive till I finally close my app. Which means the script
        obviously is not done processing.

        Any thoughts?

        Regards,
        -skanitkar

        --- In perlguitest@yahoogroups.com, "Dennis K. Paulsen"
        <ctrondlpaulsden@y...> wrote:
        > A couple of thoughts on this:
        >
        > * Your application may be taking more then 3 seconds to load up,
        > display applicable windows, and become ready for keyboard input, so
        > try using WaitWindow in place of any sleep statement. Note:
        Notepad
        > may be working with it because it is loading up in under 3 seconds
        > and is ready to accept the input.
        >
        > * Double-check the parameters you are currently using for
        > WaitWindowLike, because a value of 60 for the window class is
        > incorrect. You may wish to use the simpler WaitWindow function
        > instead: WaitWindow(TITLERX, WAIT); which makes it easier.
        >
        > * WaitWindowLike returns the first window found matching the search
        > criteria, so you could use that value instead of calling
        > FindWindowLike too. However, if you're also wanting to see your
        > primary window's children, then you could use FindWindowLike and
        > specify the value previously discussed as the window to start
        > under. Outlined in the example below.
        >
        > * Also, if you want to press <Enter> using SendKeys, use '~'
        > or '{ENTER}' in place of "\n"; which is actually just for CRLF.
        >
        >
        > The following !untested! partial example (based off your code)
        > includes these thoughts:
        >
        > my $title = "Powersafe Actions Configuration";
        >
        > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
        > my $window = WaitWindow($title, 60);
        > if (not $window) {
        > die("Window not found!: $title");
        > }
        >
        > # Window is loaded up, so it should be ready for input
        > SendKeys("admin~"); # Send string and an <Enter>
        >
        > # Now show children (text boxes, etc.) of $window
        > foreach my $child ( FindWindowLike($window) ) {
        > # Show Window Ids and any readily available text (for labels,
        > # text boxes, etc.)
        > print sprintf("Window Id: 0x%08X Window Text: '%s'\n",
        > $child, WMGetText($child));
        > }
        >
        >
        > Regards,
        > Dennis K. Paulsen
        >
        > > > --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...>
        > > wrote:
        > > > > Hi,
        > > > >
        > > > > I am new to this forum. I am unable to figure out why I cant
        > seem
        > > > to
        > > > > send input to the textbox in my Application. My code:
        > > > >
        > > > > use Win32::GuiTest qw/GetChildWindows WMSetText WMGetText
        > > > > WaitWindowLike IsWindowEnabled PushButton SendKeys
        > FindWindowLike
        > > > > GetWindowText
        > > > > GetClassName GetChildDepth GetDesktopWindow
        > > SetForegroundWindow/;
        > > > >
        > > > >
        > > > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
        > > > > sleep 3;
        > > > >
        > > > > SendKeys("admin\n");
        > > > >
        > > > > $title = "Powersafe Actions Configuration"; # title of window
        > to
        > > > > search for
        > > > > WaitWindowLike(0, $title, 60);
        > > > > @mywindow = FindWindowLike(0, $title);
        > > > > foreach(@mywindow){print "Window ". sprintf "%lx\n",$_;}
        > > > >
        > > > > My application does open with the focus set on the first
        > textbox,
        > > > but
        > > > > neither do the keys get sent, nor does anything get printed.
        > > > >
        > > > > Please help,
        > > > >
        > > > > Regards,
        > > > > -skanitkar
      • shsk7203
        Do not know how or why, since the code is still the same, but the script works for me now. Thanks. ... so ... seconds ... search ... ... cant
        Message 3 of 7 , Jul 4 5:30 AM
        • 0 Attachment
          Do not know how or why, since the code is still the same, but the
          script works for me now.

          Thanks.


          --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...> wrote:
          > Thanks a bunch. Wonderful information.
          >
          > After a few debug tricks I just realised that the problem lies
          > elsewhere. Once my Powersafe App loads, it's like the app has taken
          > over. I put in a simple print("Am I printing") before and after the
          > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
          > and the print after does not get printed. also, the perl shell also
          > stays alive till I finally close my app. Which means the script
          > obviously is not done processing.
          >
          > Any thoughts?
          >
          > Regards,
          > -skanitkar
          >
          > --- In perlguitest@yahoogroups.com, "Dennis K. Paulsen"
          > <ctrondlpaulsden@y...> wrote:
          > > A couple of thoughts on this:
          > >
          > > * Your application may be taking more then 3 seconds to load up,
          > > display applicable windows, and become ready for keyboard input,
          so
          > > try using WaitWindow in place of any sleep statement. Note:
          > Notepad
          > > may be working with it because it is loading up in under 3
          seconds
          > > and is ready to accept the input.
          > >
          > > * Double-check the parameters you are currently using for
          > > WaitWindowLike, because a value of 60 for the window class is
          > > incorrect. You may wish to use the simpler WaitWindow function
          > > instead: WaitWindow(TITLERX, WAIT); which makes it easier.
          > >
          > > * WaitWindowLike returns the first window found matching the
          search
          > > criteria, so you could use that value instead of calling
          > > FindWindowLike too. However, if you're also wanting to see your
          > > primary window's children, then you could use FindWindowLike and
          > > specify the value previously discussed as the window to start
          > > under. Outlined in the example below.
          > >
          > > * Also, if you want to press <Enter> using SendKeys, use '~'
          > > or '{ENTER}' in place of "\n"; which is actually just for CRLF.
          > >
          > >
          > > The following !untested! partial example (based off your code)
          > > includes these thoughts:
          > >
          > > my $title = "Powersafe Actions Configuration";
          > >
          > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
          > > my $window = WaitWindow($title, 60);
          > > if (not $window) {
          > > die("Window not found!: $title");
          > > }
          > >
          > > # Window is loaded up, so it should be ready for input
          > > SendKeys("admin~"); # Send string and an <Enter>
          > >
          > > # Now show children (text boxes, etc.) of $window
          > > foreach my $child ( FindWindowLike($window) ) {
          > > # Show Window Ids and any readily available text (for labels,
          > > # text boxes, etc.)
          > > print sprintf("Window Id: 0x%08X Window Text: '%s'\n",
          > > $child, WMGetText($child));
          > > }
          > >
          > >
          > > Regards,
          > > Dennis K. Paulsen
          > >
          > > > > --- In perlguitest@yahoogroups.com, "shsk7203"
          <shsk7203@y...>
          > > > wrote:
          > > > > > Hi,
          > > > > >
          > > > > > I am new to this forum. I am unable to figure out why I
          cant
          > > seem
          > > > > to
          > > > > > send input to the textbox in my Application. My code:
          > > > > >
          > > > > > use Win32::GuiTest qw/GetChildWindows WMSetText WMGetText
          > > > > > WaitWindowLike IsWindowEnabled PushButton SendKeys
          > > FindWindowLike
          > > > > > GetWindowText
          > > > > > GetClassName GetChildDepth GetDesktopWindow
          > > > SetForegroundWindow/;
          > > > > >
          > > > > >
          > > > > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
          > > > > > sleep 3;
          > > > > >
          > > > > > SendKeys("admin\n");
          > > > > >
          > > > > > $title = "Powersafe Actions Configuration"; # title of
          window
          > > to
          > > > > > search for
          > > > > > WaitWindowLike(0, $title, 60);
          > > > > > @mywindow = FindWindowLike(0, $title);
          > > > > > foreach(@mywindow){print "Window ". sprintf "%lx\n",$_;}
          > > > > >
          > > > > > My application does open with the focus set on the first
          > > textbox,
          > > > > but
          > > > > > neither do the keys get sent, nor does anything get printed.
          > > > > >
          > > > > > Please help,
          > > > > >
          > > > > > Regards,
          > > > > > -skanitkar
        • Dennis K. Paulsen
          One other observation... When you call PSActions, you aren t use the Windows start command, so the system() call will wait for PSActions to exit before it
          Message 4 of 7 , Jul 4 9:04 AM
          • 0 Attachment
            One other observation... When you call PSActions, you aren't use
            the Windows start command, so the system() call will wait for
            PSActions to exit before it continues. Try the following in the
            future:

            system("start C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");

            Regards,
            Dennis K. Paulsen

            --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...> wrote:
            > Thanks a bunch. Wonderful information.
            >
            > After a few debug tricks I just realised that the problem lies
            > elsewhere. Once my Powersafe App loads, it's like the app has
            taken
            > over. I put in a simple print("Am I printing") before and after
            the
            > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
            > and the print after does not get printed. also, the perl shell
            also
            > stays alive till I finally close my app. Which means the script
            > obviously is not done processing.
            >
            > Any thoughts?
            >
            > Regards,
            > -skanitkar
            >
            > --- In perlguitest@yahoogroups.com, "Dennis K. Paulsen"
            > <ctrondlpaulsden@y...> wrote:
            > > A couple of thoughts on this:
            > >
            > > * Your application may be taking more then 3 seconds to load up,
            > > display applicable windows, and become ready for keyboard input,
            so
            > > try using WaitWindow in place of any sleep statement. Note:
            > Notepad
            > > may be working with it because it is loading up in under 3
            seconds
            > > and is ready to accept the input.
            > >
            > > * Double-check the parameters you are currently using for
            > > WaitWindowLike, because a value of 60 for the window class is
            > > incorrect. You may wish to use the simpler WaitWindow function
            > > instead: WaitWindow(TITLERX, WAIT); which makes it easier.
            > >
            > > * WaitWindowLike returns the first window found matching the
            search
            > > criteria, so you could use that value instead of calling
            > > FindWindowLike too. However, if you're also wanting to see your
            > > primary window's children, then you could use FindWindowLike and
            > > specify the value previously discussed as the window to start
            > > under. Outlined in the example below.
            > >
            > > * Also, if you want to press <Enter> using SendKeys, use '~'
            > > or '{ENTER}' in place of "\n"; which is actually just for CRLF.
            > >
            > >
            > > The following !untested! partial example (based off your code)
            > > includes these thoughts:
            > >
            > > my $title = "Powersafe Actions Configuration";
            > >
            > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
            > > my $window = WaitWindow($title, 60);
            > > if (not $window) {
            > > die("Window not found!: $title");
            > > }
            > >
            > > # Window is loaded up, so it should be ready for input
            > > SendKeys("admin~"); # Send string and an <Enter>
            > >
            > > # Now show children (text boxes, etc.) of $window
            > > foreach my $child ( FindWindowLike($window) ) {
            > > # Show Window Ids and any readily available text (for
            labels,
            > > # text boxes, etc.)
            > > print sprintf("Window Id: 0x%08X Window Text: '%s'\n",
            > > $child, WMGetText($child));
            > > }
            > >
            > >
            > > Regards,
            > > Dennis K. Paulsen
            > >
            > > > > --- In perlguitest@yahoogroups.com, "shsk7203"
            <shsk7203@y...>
            > > > wrote:
            > > > > > Hi,
            > > > > >
            > > > > > I am new to this forum. I am unable to figure out why I
            cant
            > > seem
            > > > > to
            > > > > > send input to the textbox in my Application. My code:
            > > > > >
            > > > > > use Win32::GuiTest qw/GetChildWindows WMSetText WMGetText
            > > > > > WaitWindowLike IsWindowEnabled PushButton SendKeys
            > > FindWindowLike
            > > > > > GetWindowText
            > > > > > GetClassName GetChildDepth GetDesktopWindow
            > > > SetForegroundWindow/;
            > > > > >
            > > > > >
            > > > > > system("C:\\Win32-GuiTest-1.50\\Powersafe\\PSActions");
            > > > > > sleep 3;
            > > > > >
            > > > > > SendKeys("admin\n");
            > > > > >
            > > > > > $title = "Powersafe Actions Configuration"; # title of
            window
            > > to
            > > > > > search for
            > > > > > WaitWindowLike(0, $title, 60);
            > > > > > @mywindow = FindWindowLike(0, $title);
            > > > > > foreach(@mywindow){print "Window ". sprintf "%lx\n",$_;}
            > > > > >
            > > > > > My application does open with the focus set on the first
            > > textbox,
            > > > > but
            > > > > > neither do the keys get sent, nor does anything get
            printed.
            > > > > >
            > > > > > Please help,
            > > > > >
            > > > > > Regards,
            > > > > > -skanitkar
          Your message has been successfully submitted and would be delivered to recipients shortly.