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

GetWindowRect problem

Expand Messages
  • miles_gould
    I m trying to test a program that was built with ILOG and so exports no useful subwindows to be found by FindWindowLike. Hence, all interaction has to be done
    Message 1 of 4 , Nov 7, 2003
    • 0 Attachment
      I'm trying to test a program that was built with ILOG and so exports
      no useful subwindows to be found by FindWindowLike. Hence, all
      interaction has to be done with explicit key and mouse events. I'm
      trying to click on a button given a knowledge of its position within
      a window: you would have thought this would be a fairly simple matter
      of

      my ($left, $top) = GetWindowRect($win);
      MoveMouseAbsPix($left + $xoffset, $top + $yoffset);
      SendMouse("{LEFTDOWN}");
      SendMouse("{LEFTUP}");

      except that GetWindowRect returns the top-left corner of the window
      as being (0,0), which it isn't. So I tried ClientToScreen, but that
      doesn't return any useful output (in fact, I've just printed the
      output of Dumper(ClientToScreen($win, $xcoord, $ycoord)) and it
      doesn't seem to return any output at all) and it leaves its arguments
      unchanged.

      Any idea what I can do? I'm using Win32::GuiTest v1.3, and
      Activestate Perl build 806, version 5.8.0 running under Win 2K
      Professional.

      Thanks in advance,
      Miles.
    • ted
      I have a similar situation. The way I solved it was to move the window to a known location on the screen. Be sure to account for different screen resolutions
      Message 2 of 4 , Nov 7, 2003
      • 0 Attachment
        I have a similar situation. The way I solved it was to move the window
        to a known location on the screen. Be sure to account for different
        screen resolutions if, like me, you cannot use 0,0.

        Tom..

        -----Original Message-----
        From: miles_gould [mailto:miles_gould@...]
        Sent: Friday, November 07, 2003 6:59 AM
        To: perlguitest@yahoogroups.com
        Subject: [perlguitest] GetWindowRect problem

        I'm trying to test a program that was built with ILOG and so exports
        no useful subwindows to be found by FindWindowLike. Hence, all
        interaction has to be done with explicit key and mouse events. I'm
        trying to click on a button given a knowledge of its position within
        a window: you would have thought this would be a fairly simple matter
        of

        my ($left, $top) = GetWindowRect($win);
        MoveMouseAbsPix($left + $xoffset, $top + $yoffset);
        SendMouse("{LEFTDOWN}");
        SendMouse("{LEFTUP}");

        except that GetWindowRect returns the top-left corner of the window
        as being (0,0), which it isn't. So I tried ClientToScreen, but that
        doesn't return any useful output (in fact, I've just printed the
        output of Dumper(ClientToScreen($win, $xcoord, $ycoord)) and it
        doesn't seem to return any output at all) and it leaves its arguments
        unchanged.

        Any idea what I can do? I'm using Win32::GuiTest v1.3, and
        Activestate Perl build 806, version 5.8.0 running under Win 2K
        Professional.

        Thanks in advance,
        Miles.





        Yahoo! Groups Sponsor


        ADVERTISEMENT

        <http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=1705
        006951:HM/A=1853619/R=0/SIG=11tp41t7d/*http:/www.netflix.com/Default?mqs
        o=60178356&partid=4116719> click here


        <http://us.adserver.yahoo.com/l?M=267637.4116719.5338353.1261774/D=egrou
        pmail/S=:HM/A=1853619/rand=294540804>

        To unsubscribe from this group, send an email to:
        perlguitest-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to the Yahoo!
        <http://docs.yahoo.com/info/terms/> Terms of Service.


        [Non-text portions of this message have been removed]
      • miles_gould
        ... window ... Thanks! I d thought of that, but couldn t see how to do it - I couldn t see anything like MoveWindow or SetWindowRect in Win32::GuiTest, and I
        Message 3 of 4 , Nov 10, 2003
        • 0 Attachment
          --- In perlguitest@yahoogroups.com, "ted" <ted@o...> wrote:
          > I have a similar situation. The way I solved it was to move the
          window
          > to a known location on the screen. Be sure to account for different
          > screen resolutions if, like me, you cannot use 0,0.

          Thanks! I'd thought of that, but couldn't see how to do it - I
          couldn't see anything like MoveWindow or SetWindowRect in
          Win32::GuiTest, and I can't get Win32::API to build on my machine.
          Are you using the latter?

          Miles.
        • Dennis K. Paulsen
          Provided you are using Win32::GuiTest v1.49 or later (available from the Files section of this Yahoo! group) a SetWindowPos method is available. Below is an
          Message 4 of 4 , Nov 12, 2003
          • 0 Attachment
            Provided you are using Win32::GuiTest v1.49 or later (available from
            the Files section of this Yahoo! group) a SetWindowPos method is
            available. Below is an example, I hope it may help:


            #!/usr/bin/perl

            ## Pragmas/Directives/etc.
            use strict;
            use warnings;

            # Note: Using Win32::GuiTest v1.49 available
            # from the files section of this Yahoo group.
            use Win32::GuiTest qw/
            SetWindowPos
            FindWindowLike
            GetWindowRect
            /;

            ## Constants
            sub HWND_TOP() { 0; }

            ## Core

            # Get window handle. Using Notepad as an example.
            my ($win) = FindWindowLike(0, 'Notepad') or die('Unable to find a
            window!');

            # Determine current width and height of the window, so we can
            maintain those values
            # in the SetWindowPos call.
            my ($left, $top, $right, $bottom) = GetWindowRect($win);
            my ($w, $h) = ($right-$left, $bottom-$top);

            # Set window position to 0x0
            SetWindowPos($win, HWND_TOP, 0, 0, $w, $h, 0);


            Regards,
            Dennis K. Paulsen

            --- In perlguitest@yahoogroups.com, "miles_gould" <miles_gould@y...>
            wrote:
            > --- In perlguitest@yahoogroups.com, "ted" <ted@o...> wrote:
            > > I have a similar situation. The way I solved it was to move the
            > window
            > > to a known location on the screen. Be sure to account for
            different
            > > screen resolutions if, like me, you cannot use 0,0.
            >
            > Thanks! I'd thought of that, but couldn't see how to do it - I
            > couldn't see anything like MoveWindow or SetWindowRect in
            > Win32::GuiTest, and I can't get Win32::API to build on my machine.
            > Are you using the latter?
            >
            > Miles.
          Your message has been successfully submitted and would be delivered to recipients shortly.