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

SelTreeViewItemPath gets stuck in endless loop

Expand Messages
  • Tim Mitchell
    Bug to report... SelTreeViewItemPath gets stuck in endless loop if the item you are trying to select doesn t exist on the tree. This function needs to return a
    Message 1 of 11 , Jul 11 7:02 AM
    • 0 Attachment
      Bug to report...

      SelTreeViewItemPath gets stuck in endless loop if the item you are
      trying to select doesn't exist on the tree. This function needs to
      return a boolean result indicating success or failure.

      I tried to use it to verify that an item does not exist on the tree.

      Tim Mitchell
    • Piotr Kaluski
      Can you create a bug report in source forge? Please provide a description how to reproduce this bug quickly --Piotr
      Message 2 of 11 , Jul 12 11:45 PM
      • 0 Attachment
        Can you create a bug report in source forge? Please provide a
        description how to reproduce this bug quickly
        --Piotr

        --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@...> wrote:
        >
        > Bug to report...
        >
        > SelTreeViewItemPath gets stuck in endless loop if the item you are
        > trying to select doesn't exist on the tree. This function needs to
        > return a boolean result indicating success or failure.
        >
        > I tried to use it to verify that an item does not exist on the tree.
        >
        > Tim Mitchell
        >
      • Tim Mitchell
        I will gladly report this in source forge when I am able to duplicate it in an application that others can run. I tried to reproduce the bug with this script
        Message 3 of 11 , Jul 13 9:10 AM
        • 0 Attachment
          I will gladly report this in source forge when I am able to
          duplicate it in an application that others can run.

          I tried to reproduce the bug with this script that opens Windows
          Explorer and tries to select some items on the left TreeView.

          I get different problems this time. It does not duplicate the
          endless loop. Instead, SelTreeViewItemPath() fails to select
          anything but the root node, and even then it doesn't highlight the
          selected item.

          On the application that I'm testing, items on the tree are selected
          and highlighted. The Endless loop happens when I intentionally try
          to select an item that doesn't exist in the "folders" that do exist.

          #!perl -w
          #####################################################################
          ##
          # EndlessLoopBug.pl Tim Mitchell July 13 2006
          #
          # Win32-GuiTest script attempting to reproduce a bug in
          SelectTargetTreeItem,
          # This script opens Windows Explorer
          #####################################################################
          ##
          use Win32::GuiTest qw(:ALL);

          system("start C:\\WINDOWS\\explorer.exe");
          sleep 1; #Wait for Windows\Explorer to get started
          # Explorer opens by default on My Documents folder
          # with "My Documents" in the title bar.
          #Finding the handle of the TreeView
          my @ExplorerWindow = FindWindowLike(undef, "My Documents");
          my @OuterFrame = FindWindowLike($ExplorerWindow[0], "", "BaseBar");
          my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
          my @TreeWindow = FindWindowLike($InnerFrame[0], "", "SysTreeView32");
          # Watch eplorer while this runs. It starts on My Documents
          sleep 3;
          SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");
          # Nothing changed. My Pictures was NOT selected
          sleep 3;
          SelTreeViewItemPath($TreeWindow[0], "Desktop");
          # Desktop was selected but not highlighted in the tree
          sleep 3;
          SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
          Pictures");
          # Desktop is still selected but not highlighted
          sleep 3;
          SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
          (dgdf )");
          # Makes not difference
          --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@...>
          wrote:
          >
          > Can you create a bug report in source forge? Please provide a
          > description how to reproduce this bug quickly
          > --Piotr
          >
          > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
          wrote:
          > >
          > > Bug to report...
          > >
          > > SelTreeViewItemPath gets stuck in endless loop if the item you
          are
          > > trying to select doesn't exist on the tree. This function needs
          to
          > > return a boolean result indicating success or failure.
          > >
          > > I tried to use it to verify that an item does not exist on the
          tree.
          > >
          > > Tim Mitchell
          > >
          >
        • brentje
          I ve been having some fun with SelTreeViewItemPath lately myself, so I think I can explain why it selects the Desktop in your example but doesn t highlight
          Message 4 of 11 , Jul 17 7:10 AM
          • 0 Attachment
            I've been having some fun with SelTreeViewItemPath lately myself, so I
            think I can explain why it selects the "Desktop" in your example but
            doesn't highlight it, and the endless loop.

            SelTreeViewItemPath starts off selecting the root node when it begins
            it's search for the item you want. It then calls the TVPathWalk
            internal function to find the right node. Inside TVPathWalk, it
            starts a loop: while( $hItem != 0 ). At this point, $hItem is the
            handle to the root node. It then calls the SendMessage function for
            TVM_GETITEM, passing in the handle to the root node as the place to
            start the search, and the text that you are looking for under the root
            node. If you send in more then one string to search for (eg
            "Desktop|My Documents"), it will break it into parts and send the
            first part. If it finds it, great...it will return the handle to the
            item. Or if you've passed in something like "Desktop|My Documents",
            it will call itself recursively for the next item in the path that you
            want, passing in the handle to the item it just found ("Desktop"). If
            it doesn't find anything, it will return 0. That's why the root node
            is selected but not highlighted when it can't find anything...it's
            trying to select the item with the handle of 0, which doesn't exist.
            In your example program, the first call to SelTreeViewItemPath
            (SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");)
            will always fail because you're not sending in the proper path. The
            path should start off with Desktop since that's the root node. The
            next 2 worked for me when I ran the program though. And the last call
            just selected (but not highlighted) the Desktop again, because it
            couldn't find that path.

            The endless loop comes into play when TVPathWalk calls itself
            recursively, AND you pass in a path where the last selectable item has
            no children under it (eg "Desktop|My Documents|My Pictures|(dgdf )").
            So it comes in, checks to see if we've found the right path to this
            point ("My Pictures", which is there), checks to see if you given it
            more parts under "My Pictures" to look for (you have, "(dgdf )"),
            checks to see if "My Pictures" actually has children (it
            doesn't)...and that's where the bug is. $hItem does not equal 0, it
            equals the handle to the "My Pictures" node. Since there are more
            parts to look for but no children under "My Pictures", it will
            continuously check "My Pictures" looking for children that it will
            never find. Change that last call to look for "Desktop|My
            Documents|My Pictures|(dgdf )", and you'll have your endless loop.

            Brent

            --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@...> wrote:
            >
            > I will gladly report this in source forge when I am able to
            > duplicate it in an application that others can run.
            >
            > I tried to reproduce the bug with this script that opens Windows
            > Explorer and tries to select some items on the left TreeView.
            >
            > I get different problems this time. It does not duplicate the
            > endless loop. Instead, SelTreeViewItemPath() fails to select
            > anything but the root node, and even then it doesn't highlight the
            > selected item.
            >
            > On the application that I'm testing, items on the tree are selected
            > and highlighted. The Endless loop happens when I intentionally try
            > to select an item that doesn't exist in the "folders" that do exist.
            >
            > #!perl -w
            > #####################################################################
            > ##
            > # EndlessLoopBug.pl Tim Mitchell July 13 2006
            > #
            > # Win32-GuiTest script attempting to reproduce a bug in
            > SelectTargetTreeItem,
            > # This script opens Windows Explorer
            > #####################################################################
            > ##
            > use Win32::GuiTest qw(:ALL);
            >
            > system("start C:\\WINDOWS\\explorer.exe");
            > sleep 1; #Wait for Windows\Explorer to get started
            > # Explorer opens by default on My Documents folder
            > # with "My Documents" in the title bar.
            > #Finding the handle of the TreeView
            > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
            > my @OuterFrame = FindWindowLike($ExplorerWindow[0], "", "BaseBar");
            > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
            > my @TreeWindow = FindWindowLike($InnerFrame[0], "", "SysTreeView32");
            > # Watch eplorer while this runs. It starts on My Documents
            > sleep 3;
            > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");
            > # Nothing changed. My Pictures was NOT selected
            > sleep 3;
            > SelTreeViewItemPath($TreeWindow[0], "Desktop");
            > # Desktop was selected but not highlighted in the tree
            > sleep 3;
            > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
            > Pictures");
            > # Desktop is still selected but not highlighted
            > sleep 3;
            > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
            > (dgdf )");
            > # Makes not difference
            > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@>
            > wrote:
            > >
            > > Can you create a bug report in source forge? Please provide a
            > > description how to reproduce this bug quickly
            > > --Piotr
            > >
            > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
            > wrote:
            > > >
            > > > Bug to report...
            > > >
            > > > SelTreeViewItemPath gets stuck in endless loop if the item you
            > are
            > > > trying to select doesn't exist on the tree. This function needs
            > to
            > > > return a boolean result indicating success or failure.
            > > >
            > > > I tried to use it to verify that an item does not exist on the
            > tree.
            > > >
            > > > Tim Mitchell
            > > >
            > >
            >
          • Tim Mitchell
            Thanks Brent, OK, I added Desktop| to the front of the parameter string in the call to SelTreeViewItemPath in my example. Yes, it does get stuck in a loop.
            Message 5 of 11 , Jul 17 2:46 PM
            • 0 Attachment
              Thanks Brent,

              OK, I added "Desktop|" to the front of the parameter string in the
              call to SelTreeViewItemPath in my example. Yes, it does get stuck in
              a loop. I'll report it in Source later today or tomorrow after I
              teach myself how to use the bug reporting procedure.

              Tim
              --- In perlguitest@yahoogroups.com, "brentje" <brentje@...> wrote:
              >
              > I've been having some fun with SelTreeViewItemPath lately myself,
              so I
              > think I can explain why it selects the "Desktop" in your example
              but
              > doesn't highlight it, and the endless loop.
              >
              > SelTreeViewItemPath starts off selecting the root node when it
              begins
              > it's search for the item you want. It then calls the TVPathWalk
              > internal function to find the right node. Inside TVPathWalk, it
              > starts a loop: while( $hItem != 0 ). At this point, $hItem is the
              > handle to the root node. It then calls the SendMessage function
              for
              > TVM_GETITEM, passing in the handle to the root node as the place to
              > start the search, and the text that you are looking for under the
              root
              > node. If you send in more then one string to search for (eg
              > "Desktop|My Documents"), it will break it into parts and send the
              > first part. If it finds it, great...it will return the handle to
              the
              > item. Or if you've passed in something like "Desktop|My
              Documents",
              > it will call itself recursively for the next item in the path that
              you
              > want, passing in the handle to the item it just found
              ("Desktop"). If
              > it doesn't find anything, it will return 0. That's why the root
              node
              > is selected but not highlighted when it can't find anything...it's
              > trying to select the item with the handle of 0, which doesn't
              exist.
              > In your example program, the first call to SelTreeViewItemPath
              > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");)
              > will always fail because you're not sending in the proper path.
              The
              > path should start off with Desktop since that's the root node. The
              > next 2 worked for me when I ran the program though. And the last
              call
              > just selected (but not highlighted) the Desktop again, because it
              > couldn't find that path.
              >
              > The endless loop comes into play when TVPathWalk calls itself
              > recursively, AND you pass in a path where the last selectable item
              has
              > no children under it (eg "Desktop|My Documents|My Pictures|
              (dgdf )").
              > So it comes in, checks to see if we've found the right path to
              this
              > point ("My Pictures", which is there), checks to see if you given
              it
              > more parts under "My Pictures" to look for (you have, "(dgdf )"),
              > checks to see if "My Pictures" actually has children (it
              > doesn't)...and that's where the bug is. $hItem does not equal 0,
              it
              > equals the handle to the "My Pictures" node. Since there are more
              > parts to look for but no children under "My Pictures", it will
              > continuously check "My Pictures" looking for children that it will
              > never find. Change that last call to look for "Desktop|My
              > Documents|My Pictures|(dgdf )", and you'll have your endless loop.
              >
              > Brent
              >
              > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
              wrote:
              > >
              > > I will gladly report this in source forge when I am able to
              > > duplicate it in an application that others can run.
              > >
              > > I tried to reproduce the bug with this script that opens Windows
              > > Explorer and tries to select some items on the left TreeView.
              > >
              > > I get different problems this time. It does not duplicate the
              > > endless loop. Instead, SelTreeViewItemPath() fails to select
              > > anything but the root node, and even then it doesn't highlight
              the
              > > selected item.
              > >
              > > On the application that I'm testing, items on the tree are
              selected
              > > and highlighted. The Endless loop happens when I intentionally
              try
              > > to select an item that doesn't exist in the "folders" that do
              exist.
              > >
              > > #!perl -w
              > >
              #####################################################################
              > > ##
              > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
              > > #
              > > # Win32-GuiTest script attempting to reproduce a bug in
              > > SelectTargetTreeItem,
              > > # This script opens Windows Explorer
              > >
              #####################################################################
              > > ##
              > > use Win32::GuiTest qw(:ALL);
              > >
              > > system("start C:\\WINDOWS\\explorer.exe");
              > > sleep 1; #Wait for Windows\Explorer to get started
              > > # Explorer opens by default on My Documents folder
              > > # with "My Documents" in the title bar.
              > > #Finding the handle of the TreeView
              > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
              > > my @OuterFrame = FindWindowLike($ExplorerWindow
              [0], "", "BaseBar");
              > > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
              > > my @TreeWindow = FindWindowLike($InnerFrame
              [0], "", "SysTreeView32");
              > > # Watch eplorer while this runs. It starts on My Documents
              > > sleep 3;
              > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");
              > > # Nothing changed. My Pictures was NOT selected
              > > sleep 3;
              > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
              > > # Desktop was selected but not highlighted in the tree
              > > sleep 3;
              > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
              > > Pictures");
              > > # Desktop is still selected but not highlighted
              > > sleep 3;
              > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
              > > (dgdf )");
              > > # Makes not difference
              > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@>
              > > wrote:
              > > >
              > > > Can you create a bug report in source forge? Please provide a
              > > > description how to reproduce this bug quickly
              > > > --Piotr
              > > >
              > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
              > > wrote:
              > > > >
              > > > > Bug to report...
              > > > >
              > > > > SelTreeViewItemPath gets stuck in endless loop if the item
              you
              > > are
              > > > > trying to select doesn't exist on the tree. This function
              needs
              > > to
              > > > > return a boolean result indicating success or failure.
              > > > >
              > > > > I tried to use it to verify that an item does not exist on
              the
              > > tree.
              > > > >
              > > > > Tim Mitchell
              > > > >
              > > >
              > >
              >
            • Piotr Kaluski
              Hi, I have added GuiTest.pm file with a fix. Could you please try if it works? Just take the file and replace the current one in your perl library directory
              Message 6 of 11 , Oct 13, 2006
              • 0 Attachment
                Hi,
                I have added GuiTest.pm file with a fix. Could you please try if it
                works? Just take the file and replace the current one in your perl
                library directory (something like perl\site\lib\win32\)

                It works at least for me.

                See below for diffs.

                Brent, I am impressed by your thorough analysis. This is actually your
                fix, because after reading your post it took me 10 minutes to
                implement a solution. Thanks for your help.

                Let me know if it works for you.


                diff -c -r1.40 guitest.pm
                *** guitest.pm 29 Nov 2005 03:50:46 -0000 1.40
                --- guitest.pm 13 Oct 2006 20:33:00 -0000
                ***************
                *** 89,94 ****
                --- 89,95 ----

                package Win32::GuiTest;

                + use Carp;
                use strict;
                use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $debug %EXPORT_TAGS);

                ***************
                *** 1332,1338 ****
                $max_buf,
                $delay,
                @parts );
                ! }
                }else{
                $hItem = SendMessage( $hwnd,
                TVM_GETNEXTITEM(),
                --- 1333,1342 ----
                $max_buf,
                $delay,
                @parts );
                ! }else{
                ! carp "No children under $parts[ 0 ]";
                ! return 0;
                ! }
                }else{
                $hItem = SendMessage( $hwnd,
                TVM_GETNEXTITEM(),
                ***************
                *** 1340,1345 ****
                --- 1344,1350 ----
                $hItem );
                }
                }
                + carp "No such child $parts[ 0 ]";
                return 0;
                }


                --- In perlguitest@yahoogroups.com, "brentje" <brentje@...> wrote:
                >
                > I've been having some fun with SelTreeViewItemPath lately myself, so I
                > think I can explain why it selects the "Desktop" in your example but
                > doesn't highlight it, and the endless loop.
                >
                > SelTreeViewItemPath starts off selecting the root node when it begins
                > it's search for the item you want. It then calls the TVPathWalk
                > internal function to find the right node. Inside TVPathWalk, it
                > starts a loop: while( $hItem != 0 ). At this point, $hItem is the
                > handle to the root node. It then calls the SendMessage function for
                > TVM_GETITEM, passing in the handle to the root node as the place to
                > start the search, and the text that you are looking for under the root
                > node. If you send in more then one string to search for (eg
                > "Desktop|My Documents"), it will break it into parts and send the
                > first part. If it finds it, great...it will return the handle to the
                > item. Or if you've passed in something like "Desktop|My Documents",
                > it will call itself recursively for the next item in the path that you
                > want, passing in the handle to the item it just found ("Desktop"). If
                > it doesn't find anything, it will return 0. That's why the root node
                > is selected but not highlighted when it can't find anything...it's
                > trying to select the item with the handle of 0, which doesn't exist.
                > In your example program, the first call to SelTreeViewItemPath
                > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");)
                > will always fail because you're not sending in the proper path. The
                > path should start off with Desktop since that's the root node. The
                > next 2 worked for me when I ran the program though. And the last call
                > just selected (but not highlighted) the Desktop again, because it
                > couldn't find that path.
                >
                > The endless loop comes into play when TVPathWalk calls itself
                > recursively, AND you pass in a path where the last selectable item has
                > no children under it (eg "Desktop|My Documents|My Pictures|(dgdf )").
                > So it comes in, checks to see if we've found the right path to this
                > point ("My Pictures", which is there), checks to see if you given it
                > more parts under "My Pictures" to look for (you have, "(dgdf )"),
                > checks to see if "My Pictures" actually has children (it
                > doesn't)...and that's where the bug is. $hItem does not equal 0, it
                > equals the handle to the "My Pictures" node. Since there are more
                > parts to look for but no children under "My Pictures", it will
                > continuously check "My Pictures" looking for children that it will
                > never find. Change that last call to look for "Desktop|My
                > Documents|My Pictures|(dgdf )", and you'll have your endless loop.
                >
                > Brent
                >
                > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@> wrote:
                > >
                > > I will gladly report this in source forge when I am able to
                > > duplicate it in an application that others can run.
                > >
                > > I tried to reproduce the bug with this script that opens Windows
                > > Explorer and tries to select some items on the left TreeView.
                > >
                > > I get different problems this time. It does not duplicate the
                > > endless loop. Instead, SelTreeViewItemPath() fails to select
                > > anything but the root node, and even then it doesn't highlight the
                > > selected item.
                > >
                > > On the application that I'm testing, items on the tree are selected
                > > and highlighted. The Endless loop happens when I intentionally try
                > > to select an item that doesn't exist in the "folders" that do exist.
                > >
                > > #!perl -w
                > > #####################################################################
                > > ##
                > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
                > > #
                > > # Win32-GuiTest script attempting to reproduce a bug in
                > > SelectTargetTreeItem,
                > > # This script opens Windows Explorer
                > > #####################################################################
                > > ##
                > > use Win32::GuiTest qw(:ALL);
                > >
                > > system("start C:\\WINDOWS\\explorer.exe");
                > > sleep 1; #Wait for Windows\Explorer to get started
                > > # Explorer opens by default on My Documents folder
                > > # with "My Documents" in the title bar.
                > > #Finding the handle of the TreeView
                > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
                > > my @OuterFrame = FindWindowLike($ExplorerWindow[0], "", "BaseBar");
                > > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
                > > my @TreeWindow = FindWindowLike($InnerFrame[0], "", "SysTreeView32");
                > > # Watch eplorer while this runs. It starts on My Documents
                > > sleep 3;
                > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures");
                > > # Nothing changed. My Pictures was NOT selected
                > > sleep 3;
                > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
                > > # Desktop was selected but not highlighted in the tree
                > > sleep 3;
                > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
                > > Pictures");
                > > # Desktop is still selected but not highlighted
                > > sleep 3;
                > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
                > > (dgdf )");
                > > # Makes not difference
                > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@>
                > > wrote:
                > > >
                > > > Can you create a bug report in source forge? Please provide a
                > > > description how to reproduce this bug quickly
                > > > --Piotr
                > > >
                > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
                > > wrote:
                > > > >
                > > > > Bug to report...
                > > > >
                > > > > SelTreeViewItemPath gets stuck in endless loop if the item you
                > > are
                > > > > trying to select doesn't exist on the tree. This function needs
                > > to
                > > > > return a boolean result indicating success or failure.
                > > > >
                > > > > I tried to use it to verify that an item does not exist on the
                > > tree.
                > > > >
                > > > > Tim Mitchell
                > > > >
                > > >
                > >
                >
              • Tim Mitchell
                I have added GuiTest.pm file with a fix. ...added it to what? I d like to try it today, but where is it? Tim ... your ... EXPORT_TAGS); ... myself, so I ...
                Message 7 of 11 , Oct 16, 2006
                • 0 Attachment
                  "I have added GuiTest.pm file with a fix." ...added it to what? I'd
                  like to try it today, but where is it?

                  Tim
                  --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@...>
                  wrote:
                  >
                  > Hi,
                  > I have added GuiTest.pm file with a fix. Could you please try if it
                  > works? Just take the file and replace the current one in your perl
                  > library directory (something like perl\site\lib\win32\)
                  >
                  > It works at least for me.
                  >
                  > See below for diffs.
                  >
                  > Brent, I am impressed by your thorough analysis. This is actually
                  your
                  > fix, because after reading your post it took me 10 minutes to
                  > implement a solution. Thanks for your help.
                  >
                  > Let me know if it works for you.
                  >
                  >
                  > diff -c -r1.40 guitest.pm
                  > *** guitest.pm 29 Nov 2005 03:50:46 -0000 1.40
                  > --- guitest.pm 13 Oct 2006 20:33:00 -0000
                  > ***************
                  > *** 89,94 ****
                  > --- 89,95 ----
                  >
                  > package Win32::GuiTest;
                  >
                  > + use Carp;
                  > use strict;
                  > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $debug %
                  EXPORT_TAGS);
                  >
                  > ***************
                  > *** 1332,1338 ****
                  > $max_buf,
                  > $delay,
                  > @parts );
                  > ! }
                  > }else{
                  > $hItem = SendMessage( $hwnd,
                  > TVM_GETNEXTITEM(),
                  > --- 1333,1342 ----
                  > $max_buf,
                  > $delay,
                  > @parts );
                  > ! }else{
                  > ! carp "No children under $parts[ 0 ]";
                  > ! return 0;
                  > ! }
                  > }else{
                  > $hItem = SendMessage( $hwnd,
                  > TVM_GETNEXTITEM(),
                  > ***************
                  > *** 1340,1345 ****
                  > --- 1344,1350 ----
                  > $hItem );
                  > }
                  > }
                  > + carp "No such child $parts[ 0 ]";
                  > return 0;
                  > }
                  >
                  >
                  > --- In perlguitest@yahoogroups.com, "brentje" <brentje@> wrote:
                  > >
                  > > I've been having some fun with SelTreeViewItemPath lately
                  myself, so I
                  > > think I can explain why it selects the "Desktop" in your example
                  but
                  > > doesn't highlight it, and the endless loop.
                  > >
                  > > SelTreeViewItemPath starts off selecting the root node when it
                  begins
                  > > it's search for the item you want. It then calls the TVPathWalk
                  > > internal function to find the right node. Inside TVPathWalk, it
                  > > starts a loop: while( $hItem != 0 ). At this point, $hItem is
                  the
                  > > handle to the root node. It then calls the SendMessage function
                  for
                  > > TVM_GETITEM, passing in the handle to the root node as the place
                  to
                  > > start the search, and the text that you are looking for under
                  the root
                  > > node. If you send in more then one string to search for (eg
                  > > "Desktop|My Documents"), it will break it into parts and send the
                  > > first part. If it finds it, great...it will return the handle
                  to the
                  > > item. Or if you've passed in something like "Desktop|My
                  Documents",
                  > > it will call itself recursively for the next item in the path
                  that you
                  > > want, passing in the handle to the item it just found
                  ("Desktop"). If
                  > > it doesn't find anything, it will return 0. That's why the root
                  node
                  > > is selected but not highlighted when it can't find
                  anything...it's
                  > > trying to select the item with the handle of 0, which doesn't
                  exist.
                  > > In your example program, the first call to SelTreeViewItemPath
                  > > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                  Pictures");)
                  > > will always fail because you're not sending in the proper path.
                  The
                  > > path should start off with Desktop since that's the root node.
                  The
                  > > next 2 worked for me when I ran the program though. And the
                  last call
                  > > just selected (but not highlighted) the Desktop again, because it
                  > > couldn't find that path.
                  > >
                  > > The endless loop comes into play when TVPathWalk calls itself
                  > > recursively, AND you pass in a path where the last selectable
                  item has
                  > > no children under it (eg "Desktop|My Documents|My Pictures|
                  (dgdf )").
                  > > So it comes in, checks to see if we've found the right path to
                  this
                  > > point ("My Pictures", which is there), checks to see if you
                  given it
                  > > more parts under "My Pictures" to look for (you have, "(dgdf )"),
                  > > checks to see if "My Pictures" actually has children (it
                  > > doesn't)...and that's where the bug is. $hItem does not equal
                  0, it
                  > > equals the handle to the "My Pictures" node. Since there are
                  more
                  > > parts to look for but no children under "My Pictures", it will
                  > > continuously check "My Pictures" looking for children that it
                  will
                  > > never find. Change that last call to look for "Desktop|My
                  > > Documents|My Pictures|(dgdf )", and you'll have your endless
                  loop.
                  > >
                  > > Brent
                  > >
                  > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
                  wrote:
                  > > >
                  > > > I will gladly report this in source forge when I am able to
                  > > > duplicate it in an application that others can run.
                  > > >
                  > > > I tried to reproduce the bug with this script that opens
                  Windows
                  > > > Explorer and tries to select some items on the left TreeView.
                  > > >
                  > > > I get different problems this time. It does not duplicate the
                  > > > endless loop. Instead, SelTreeViewItemPath() fails to select
                  > > > anything but the root node, and even then it doesn't highlight
                  the
                  > > > selected item.
                  > > >
                  > > > On the application that I'm testing, items on the tree are
                  selected
                  > > > and highlighted. The Endless loop happens when I intentionally
                  try
                  > > > to select an item that doesn't exist in the "folders" that do
                  exist.
                  > > >
                  > > > #!perl -w
                  > > >
                  #####################################################################
                  > > > ##
                  > > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
                  > > > #
                  > > > # Win32-GuiTest script attempting to reproduce a bug in
                  > > > SelectTargetTreeItem,
                  > > > # This script opens Windows Explorer
                  > > >
                  #####################################################################
                  > > > ##
                  > > > use Win32::GuiTest qw(:ALL);
                  > > >
                  > > > system("start C:\\WINDOWS\\explorer.exe");
                  > > > sleep 1; #Wait for Windows\Explorer to get started
                  > > > # Explorer opens by default on My Documents folder
                  > > > # with "My Documents" in the title bar.
                  > > > #Finding the handle of the TreeView
                  > > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
                  > > > my @OuterFrame = FindWindowLike($ExplorerWindow
                  [0], "", "BaseBar");
                  > > > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
                  > > > my @TreeWindow = FindWindowLike($InnerFrame
                  [0], "", "SysTreeView32");
                  > > > # Watch eplorer while this runs. It starts on My Documents
                  > > > sleep 3;
                  > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                  Pictures");
                  > > > # Nothing changed. My Pictures was NOT selected
                  > > > sleep 3;
                  > > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
                  > > > # Desktop was selected but not highlighted in the tree
                  > > > sleep 3;
                  > > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
                  > > > Pictures");
                  > > > # Desktop is still selected but not highlighted
                  > > > sleep 3;
                  > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
                  > > > (dgdf )");
                  > > > # Makes not difference
                  > > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski"
                  <pkaluski@>
                  > > > wrote:
                  > > > >
                  > > > > Can you create a bug report in source forge? Please provide
                  a
                  > > > > description how to reproduce this bug quickly
                  > > > > --Piotr
                  > > > >
                  > > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell"
                  <maxquig@>
                  > > > wrote:
                  > > > > >
                  > > > > > Bug to report...
                  > > > > >
                  > > > > > SelTreeViewItemPath gets stuck in endless loop if the item
                  you
                  > > > are
                  > > > > > trying to select doesn't exist on the tree. This function
                  needs
                  > > > to
                  > > > > > return a boolean result indicating success or failure.
                  > > > > >
                  > > > > > I tried to use it to verify that an item does not exist on
                  the
                  > > > tree.
                  > > > > >
                  > > > > > Tim Mitchell
                  > > > > >
                  > > > >
                  > > >
                  > >
                  >
                • Tim Mitchell
                  I don t know where your new version of GuiTest.pm is, but I edited mine like this: 90 package Win32::GuiTest; 92 use Carp; 93 use strict; I really don know
                  Message 8 of 11 , Oct 16, 2006
                  • 0 Attachment
                    I don't know where your new version of GuiTest.pm is, but I edited
                    mine like this:

                    90 package Win32::GuiTest;

                    92 use Carp;
                    93 use strict;

                    I really don know what the + character is doing in front of
                    your "use Carp;" but I took it out.

                    and

                    1333 $max_buf,
                    1334 $delay,
                    1335 @parts );
                    1336 }else{
                    1337 carp "No children under $parts[ 0 ]";
                    1338 return 0;
                    1339 }
                    1340 }else{
                    1341 $hItem = SendMessage( $hwnd,
                    1342 TVM_GETNEXTITEM( ),
                    1343 TVGN_NEXT(),
                    1344 $hItem );
                    1345 }
                    1346 }
                    1347 + carp "No such child $parts[ 0 ]";
                    1348 return 0;
                    1349 }

                    and in lines 1336 - 1339 I have no idea what the ! characters are
                    for. They just cause compiler errors.

                    So I run my test script and get these errors:
                    No such child My Documents at EndLessLoopBug.pl line 21
                    No such child Desktop at EndLessLoopBug.pl line 24
                    No such child Desktop at EndLessLoopBug.pl line 27
                    No such child DeskTop at EndLessLoopBug.pl line 30

                    and nothing on the tree is selected. It does end gracefully.

                    Tim


                    --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@...>
                    wrote:
                    >
                    > Hi,
                    > I have added GuiTest.pm file with a fix. Could you please try if it
                    > works? Just take the file and replace the current one in your perl
                    > library directory (something like perl\site\lib\win32\)
                    >
                    > It works at least for me.
                    >
                    > See below for diffs.
                    >
                    > Brent, I am impressed by your thorough analysis. This is actually
                    your
                    > fix, because after reading your post it took me 10 minutes to
                    > implement a solution. Thanks for your help.
                    >
                    > Let me know if it works for you.
                    >
                    >
                    > diff -c -r1.40 guitest.pm
                    > *** guitest.pm 29 Nov 2005 03:50:46 -0000 1.40
                    > --- guitest.pm 13 Oct 2006 20:33:00 -0000
                    > ***************
                    > *** 89,94 ****
                    > --- 89,95 ----
                    >
                    > package Win32::GuiTest;
                    >
                    > + use Carp;
                    > use strict;
                    > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $debug %
                    EXPORT_TAGS);
                    >
                    > ***************
                    > *** 1332,1338 ****
                    > $max_buf,
                    > $delay,
                    > @parts );
                    > ! }
                    > }else{
                    > $hItem = SendMessage( $hwnd,
                    > TVM_GETNEXTITEM(),
                    > --- 1333,1342 ----
                    > $max_buf,
                    > $delay,
                    > @parts );
                    > ! }else{
                    > ! carp "No children under $parts[ 0 ]";
                    > ! return 0;
                    > ! }
                    > }else{
                    > $hItem = SendMessage( $hwnd,
                    > TVM_GETNEXTITEM(),
                    > ***************
                    > *** 1340,1345 ****
                    > --- 1344,1350 ----
                    > $hItem );
                    > }
                    > }
                    > + carp "No such child $parts[ 0 ]";
                    > return 0;
                    > }
                    >
                    >
                    > --- In perlguitest@yahoogroups.com, "brentje" <brentje@> wrote:
                    > >
                    > > I've been having some fun with SelTreeViewItemPath lately
                    myself, so I
                    > > think I can explain why it selects the "Desktop" in your example
                    but
                    > > doesn't highlight it, and the endless loop.
                    > >
                    > > SelTreeViewItemPath starts off selecting the root node when it
                    begins
                    > > it's search for the item you want. It then calls the TVPathWalk
                    > > internal function to find the right node. Inside TVPathWalk, it
                    > > starts a loop: while( $hItem != 0 ). At this point, $hItem is
                    the
                    > > handle to the root node. It then calls the SendMessage function
                    for
                    > > TVM_GETITEM, passing in the handle to the root node as the place
                    to
                    > > start the search, and the text that you are looking for under
                    the root
                    > > node. If you send in more then one string to search for (eg
                    > > "Desktop|My Documents"), it will break it into parts and send the
                    > > first part. If it finds it, great...it will return the handle
                    to the
                    > > item. Or if you've passed in something like "Desktop|My
                    Documents",
                    > > it will call itself recursively for the next item in the path
                    that you
                    > > want, passing in the handle to the item it just found
                    ("Desktop"). If
                    > > it doesn't find anything, it will return 0. That's why the root
                    node
                    > > is selected but not highlighted when it can't find
                    anything...it's
                    > > trying to select the item with the handle of 0, which doesn't
                    exist.
                    > > In your example program, the first call to SelTreeViewItemPath
                    > > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                    Pictures");)
                    > > will always fail because you're not sending in the proper path.
                    The
                    > > path should start off with Desktop since that's the root node.
                    The
                    > > next 2 worked for me when I ran the program though. And the
                    last call
                    > > just selected (but not highlighted) the Desktop again, because it
                    > > couldn't find that path.
                    > >
                    > > The endless loop comes into play when TVPathWalk calls itself
                    > > recursively, AND you pass in a path where the last selectable
                    item has
                    > > no children under it (eg "Desktop|My Documents|My Pictures|
                    (dgdf )").
                    > > So it comes in, checks to see if we've found the right path to
                    this
                    > > point ("My Pictures", which is there), checks to see if you
                    given it
                    > > more parts under "My Pictures" to look for (you have, "(dgdf )"),
                    > > checks to see if "My Pictures" actually has children (it
                    > > doesn't)...and that's where the bug is. $hItem does not equal
                    0, it
                    > > equals the handle to the "My Pictures" node. Since there are
                    more
                    > > parts to look for but no children under "My Pictures", it will
                    > > continuously check "My Pictures" looking for children that it
                    will
                    > > never find. Change that last call to look for "Desktop|My
                    > > Documents|My Pictures|(dgdf )", and you'll have your endless
                    loop.
                    > >
                    > > Brent
                    > >
                    > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
                    wrote:
                    > > >
                    > > > I will gladly report this in source forge when I am able to
                    > > > duplicate it in an application that others can run.
                    > > >
                    > > > I tried to reproduce the bug with this script that opens
                    Windows
                    > > > Explorer and tries to select some items on the left TreeView.
                    > > >
                    > > > I get different problems this time. It does not duplicate the
                    > > > endless loop. Instead, SelTreeViewItemPath() fails to select
                    > > > anything but the root node, and even then it doesn't highlight
                    the
                    > > > selected item.
                    > > >
                    > > > On the application that I'm testing, items on the tree are
                    selected
                    > > > and highlighted. The Endless loop happens when I intentionally
                    try
                    > > > to select an item that doesn't exist in the "folders" that do
                    exist.
                    > > >
                    > > > #!perl -w
                    > > >
                    #####################################################################
                    > > > ##
                    > > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
                    > > > #
                    > > > # Win32-GuiTest script attempting to reproduce a bug in
                    > > > SelectTargetTreeItem,
                    > > > # This script opens Windows Explorer
                    > > >
                    #####################################################################
                    > > > ##
                    > > > use Win32::GuiTest qw(:ALL);
                    > > >
                    > > > system("start C:\\WINDOWS\\explorer.exe");
                    > > > sleep 1; #Wait for Windows\Explorer to get started
                    > > > # Explorer opens by default on My Documents folder
                    > > > # with "My Documents" in the title bar.
                    > > > #Finding the handle of the TreeView
                    > > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
                    > > > my @OuterFrame = FindWindowLike($ExplorerWindow
                    [0], "", "BaseBar");
                    > > > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
                    > > > my @TreeWindow = FindWindowLike($InnerFrame
                    [0], "", "SysTreeView32");
                    > > > # Watch eplorer while this runs. It starts on My Documents
                    > > > sleep 3;
                    > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                    Pictures");
                    > > > # Nothing changed. My Pictures was NOT selected
                    > > > sleep 3;
                    > > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
                    > > > # Desktop was selected but not highlighted in the tree
                    > > > sleep 3;
                    > > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
                    > > > Pictures");
                    > > > # Desktop is still selected but not highlighted
                    > > > sleep 3;
                    > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
                    > > > (dgdf )");
                    > > > # Makes not difference
                    > > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski"
                    <pkaluski@>
                    > > > wrote:
                    > > > >
                    > > > > Can you create a bug report in source forge? Please provide
                    a
                    > > > > description how to reproduce this bug quickly
                    > > > > --Piotr
                    > > > >
                    > > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell"
                    <maxquig@>
                    > > > wrote:
                    > > > > >
                    > > > > > Bug to report...
                    > > > > >
                    > > > > > SelTreeViewItemPath gets stuck in endless loop if the item
                    you
                    > > > are
                    > > > > > trying to select doesn't exist on the tree. This function
                    needs
                    > > > to
                    > > > > > return a boolean result indicating success or failure.
                    > > > > >
                    > > > > > I tried to use it to verify that an item does not exist on
                    the
                    > > > tree.
                    > > > > >
                    > > > > > Tim Mitchell
                    > > > > >
                    > > > >
                    > > >
                    > >
                    >
                  • Piotr Kaluski
                    Oopss! I am sorry. It is in files section of this group. I have added only GuiTest.pm file, not the whole package. --Piotr
                    Message 9 of 11 , Oct 16, 2006
                    • 0 Attachment
                      Oopss!
                      I am sorry. It is in files section of this group. I have added only
                      GuiTest.pm file, not the whole package.

                      --Piotr


                      --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@...> wrote:
                      >
                      > "I have added GuiTest.pm file with a fix." ...added it to what? I'd
                      > like to try it today, but where is it?
                      >
                      > Tim
                      > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@>
                      > wrote:
                      > >
                      > > Hi,
                      > > I have added GuiTest.pm file with a fix. Could you please try if it
                      > > works? Just take the file and replace the current one in your perl
                      > > library directory (something like perl\site\lib\win32\)
                      > >
                      > > It works at least for me.
                      > >
                      > > See below for diffs.
                      > >
                      > > Brent, I am impressed by your thorough analysis. This is actually
                      > your
                      > > fix, because after reading your post it took me 10 minutes to
                      > > implement a solution. Thanks for your help.
                      > >
                      > > Let me know if it works for you.
                      > >
                      > >
                      > > diff -c -r1.40 guitest.pm
                      > > *** guitest.pm 29 Nov 2005 03:50:46 -0000 1.40
                      > > --- guitest.pm 13 Oct 2006 20:33:00 -0000
                      > > ***************
                      > > *** 89,94 ****
                      > > --- 89,95 ----
                      > >
                      > > package Win32::GuiTest;
                      > >
                      > > + use Carp;
                      > > use strict;
                      > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $debug %
                      > EXPORT_TAGS);
                      > >
                      > > ***************
                      > > *** 1332,1338 ****
                      > > $max_buf,
                      > > $delay,
                      > > @parts );
                      > > ! }
                      > > }else{
                      > > $hItem = SendMessage( $hwnd,
                      > > TVM_GETNEXTITEM(),
                      > > --- 1333,1342 ----
                      > > $max_buf,
                      > > $delay,
                      > > @parts );
                      > > ! }else{
                      > > ! carp "No children under $parts[ 0 ]";
                      > > ! return 0;
                      > > ! }
                      > > }else{
                      > > $hItem = SendMessage( $hwnd,
                      > > TVM_GETNEXTITEM(),
                      > > ***************
                      > > *** 1340,1345 ****
                      > > --- 1344,1350 ----
                      > > $hItem );
                      > > }
                      > > }
                      > > + carp "No such child $parts[ 0 ]";
                      > > return 0;
                      > > }
                      > >
                      > >
                      > > --- In perlguitest@yahoogroups.com, "brentje" <brentje@> wrote:
                      > > >
                      > > > I've been having some fun with SelTreeViewItemPath lately
                      > myself, so I
                      > > > think I can explain why it selects the "Desktop" in your example
                      > but
                      > > > doesn't highlight it, and the endless loop.
                      > > >
                      > > > SelTreeViewItemPath starts off selecting the root node when it
                      > begins
                      > > > it's search for the item you want. It then calls the TVPathWalk
                      > > > internal function to find the right node. Inside TVPathWalk, it
                      > > > starts a loop: while( $hItem != 0 ). At this point, $hItem is
                      > the
                      > > > handle to the root node. It then calls the SendMessage function
                      > for
                      > > > TVM_GETITEM, passing in the handle to the root node as the place
                      > to
                      > > > start the search, and the text that you are looking for under
                      > the root
                      > > > node. If you send in more then one string to search for (eg
                      > > > "Desktop|My Documents"), it will break it into parts and send the
                      > > > first part. If it finds it, great...it will return the handle
                      > to the
                      > > > item. Or if you've passed in something like "Desktop|My
                      > Documents",
                      > > > it will call itself recursively for the next item in the path
                      > that you
                      > > > want, passing in the handle to the item it just found
                      > ("Desktop"). If
                      > > > it doesn't find anything, it will return 0. That's why the root
                      > node
                      > > > is selected but not highlighted when it can't find
                      > anything...it's
                      > > > trying to select the item with the handle of 0, which doesn't
                      > exist.
                      > > > In your example program, the first call to SelTreeViewItemPath
                      > > > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                      > Pictures");)
                      > > > will always fail because you're not sending in the proper path.
                      > The
                      > > > path should start off with Desktop since that's the root node.
                      > The
                      > > > next 2 worked for me when I ran the program though. And the
                      > last call
                      > > > just selected (but not highlighted) the Desktop again, because it
                      > > > couldn't find that path.
                      > > >
                      > > > The endless loop comes into play when TVPathWalk calls itself
                      > > > recursively, AND you pass in a path where the last selectable
                      > item has
                      > > > no children under it (eg "Desktop|My Documents|My Pictures|
                      > (dgdf )").
                      > > > So it comes in, checks to see if we've found the right path to
                      > this
                      > > > point ("My Pictures", which is there), checks to see if you
                      > given it
                      > > > more parts under "My Pictures" to look for (you have, "(dgdf )"),
                      > > > checks to see if "My Pictures" actually has children (it
                      > > > doesn't)...and that's where the bug is. $hItem does not equal
                      > 0, it
                      > > > equals the handle to the "My Pictures" node. Since there are
                      > more
                      > > > parts to look for but no children under "My Pictures", it will
                      > > > continuously check "My Pictures" looking for children that it
                      > will
                      > > > never find. Change that last call to look for "Desktop|My
                      > > > Documents|My Pictures|(dgdf )", and you'll have your endless
                      > loop.
                      > > >
                      > > > Brent
                      > > >
                      > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
                      > wrote:
                      > > > >
                      > > > > I will gladly report this in source forge when I am able to
                      > > > > duplicate it in an application that others can run.
                      > > > >
                      > > > > I tried to reproduce the bug with this script that opens
                      > Windows
                      > > > > Explorer and tries to select some items on the left TreeView.
                      > > > >
                      > > > > I get different problems this time. It does not duplicate the
                      > > > > endless loop. Instead, SelTreeViewItemPath() fails to select
                      > > > > anything but the root node, and even then it doesn't highlight
                      > the
                      > > > > selected item.
                      > > > >
                      > > > > On the application that I'm testing, items on the tree are
                      > selected
                      > > > > and highlighted. The Endless loop happens when I intentionally
                      > try
                      > > > > to select an item that doesn't exist in the "folders" that do
                      > exist.
                      > > > >
                      > > > > #!perl -w
                      > > > >
                      > #####################################################################
                      > > > > ##
                      > > > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
                      > > > > #
                      > > > > # Win32-GuiTest script attempting to reproduce a bug in
                      > > > > SelectTargetTreeItem,
                      > > > > # This script opens Windows Explorer
                      > > > >
                      > #####################################################################
                      > > > > ##
                      > > > > use Win32::GuiTest qw(:ALL);
                      > > > >
                      > > > > system("start C:\\WINDOWS\\explorer.exe");
                      > > > > sleep 1; #Wait for Windows\Explorer to get started
                      > > > > # Explorer opens by default on My Documents folder
                      > > > > # with "My Documents" in the title bar.
                      > > > > #Finding the handle of the TreeView
                      > > > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
                      > > > > my @OuterFrame = FindWindowLike($ExplorerWindow
                      > [0], "", "BaseBar");
                      > > > > my @InnerFrame = FindWindowLike($OuterFrame[0], "", "BaseBar");
                      > > > > my @TreeWindow = FindWindowLike($InnerFrame
                      > [0], "", "SysTreeView32");
                      > > > > # Watch eplorer while this runs. It starts on My Documents
                      > > > > sleep 3;
                      > > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                      > Pictures");
                      > > > > # Nothing changed. My Pictures was NOT selected
                      > > > > sleep 3;
                      > > > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
                      > > > > # Desktop was selected but not highlighted in the tree
                      > > > > sleep 3;
                      > > > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My Documents|My
                      > > > > Pictures");
                      > > > > # Desktop is still selected but not highlighted
                      > > > > sleep 3;
                      > > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My Pictures
                      > > > > (dgdf )");
                      > > > > # Makes not difference
                      > > > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski"
                      > <pkaluski@>
                      > > > > wrote:
                      > > > > >
                      > > > > > Can you create a bug report in source forge? Please provide
                      > a
                      > > > > > description how to reproduce this bug quickly
                      > > > > > --Piotr
                      > > > > >
                      > > > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell"
                      > <maxquig@>
                      > > > > wrote:
                      > > > > > >
                      > > > > > > Bug to report...
                      > > > > > >
                      > > > > > > SelTreeViewItemPath gets stuck in endless loop if the item
                      > you
                      > > > > are
                      > > > > > > trying to select doesn't exist on the tree. This function
                      > needs
                      > > > > to
                      > > > > > > return a boolean result indicating success or failure.
                      > > > > > >
                      > > > > > > I tried to use it to verify that an item does not exist on
                      > the
                      > > > > tree.
                      > > > > > >
                      > > > > > > Tim Mitchell
                      > > > > > >
                      > > > > >
                      > > > >
                      > > >
                      > >
                      >
                    • Tim Mitchell
                      Piotr, Sorry I took so long in testing this. The good news is that SelTreeViewItemPath no longer gets stuck in an endless loop when the item is not found on
                      Message 10 of 11 , Feb 21, 2007
                      • 0 Attachment
                        Piotr,

                        Sorry I took so long in testing this. The good news is that
                        SelTreeViewItemPath no longer gets stuck in an endless loop when the
                        item is not found on the tree. The bad news is that it doesn't
                        return a flag of any kind to indicate whether or not it is
                        successful. If not successfule it gives an error message "No such
                        child SubsetsXXX at C:/Perl/site/lib/SMTpats/TKS.pm line 1579". In
                        this example line 1579 is the line that calls the function.

                        Tim
                        --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@...>
                        wrote:
                        >
                        > Oopss!
                        > I am sorry. It is in files section of this group. I have added only
                        > GuiTest.pm file, not the whole package.
                        >
                        > --Piotr
                        >
                        >
                        > --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@>
                        wrote:
                        > >
                        > > "I have added GuiTest.pm file with a fix." ...added it to what?
                        I'd
                        > > like to try it today, but where is it?
                        > >
                        > > Tim
                        > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@>
                        > > wrote:
                        > > >
                        > > > Hi,
                        > > > I have added GuiTest.pm file with a fix. Could you please try
                        if it
                        > > > works? Just take the file and replace the current one in your
                        perl
                        > > > library directory (something like perl\site\lib\win32\)
                        > > >
                        > > > It works at least for me.
                        > > >
                        > > > See below for diffs.
                        > > >
                        > > > Brent, I am impressed by your thorough analysis. This is
                        actually
                        > > your
                        > > > fix, because after reading your post it took me 10 minutes to
                        > > > implement a solution. Thanks for your help.
                        > > >
                        > > > Let me know if it works for you.
                        > > >
                        > > >
                        > > > diff -c -r1.40 guitest.pm
                        > > > *** guitest.pm 29 Nov 2005 03:50:46 -0000 1.40
                        > > > --- guitest.pm 13 Oct 2006 20:33:00 -0000
                        > > > ***************
                        > > > *** 89,94 ****
                        > > > --- 89,95 ----
                        > > >
                        > > > package Win32::GuiTest;
                        > > >
                        > > > + use Carp;
                        > > > use strict;
                        > > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $debug %
                        > > EXPORT_TAGS);
                        > > >
                        > > > ***************
                        > > > *** 1332,1338 ****
                        > > > $max_buf,
                        > > > $delay,
                        > > > @parts );
                        > > > ! }
                        > > > }else{
                        > > > $hItem = SendMessage( $hwnd,
                        > > > TVM_GETNEXTITEM(),
                        > > > --- 1333,1342 ----
                        > > > $max_buf,
                        > > > $delay,
                        > > > @parts );
                        > > > ! }else{
                        > > > ! carp "No children under $parts[ 0 ]";
                        > > > ! return 0;
                        > > > ! }
                        > > > }else{
                        > > > $hItem = SendMessage( $hwnd,
                        > > > TVM_GETNEXTITEM(),
                        > > > ***************
                        > > > *** 1340,1345 ****
                        > > > --- 1344,1350 ----
                        > > > $hItem );
                        > > > }
                        > > > }
                        > > > + carp "No such child $parts[ 0 ]";
                        > > > return 0;
                        > > > }
                        > > >
                        > > >
                        > > > --- In perlguitest@yahoogroups.com, "brentje" <brentje@> wrote:
                        > > > >
                        > > > > I've been having some fun with SelTreeViewItemPath lately
                        > > myself, so I
                        > > > > think I can explain why it selects the "Desktop" in your
                        example
                        > > but
                        > > > > doesn't highlight it, and the endless loop.
                        > > > >
                        > > > > SelTreeViewItemPath starts off selecting the root node when
                        it
                        > > begins
                        > > > > it's search for the item you want. It then calls the
                        TVPathWalk
                        > > > > internal function to find the right node. Inside
                        TVPathWalk, it
                        > > > > starts a loop: while( $hItem != 0 ). At this point, $hItem
                        is
                        > > the
                        > > > > handle to the root node. It then calls the SendMessage
                        function
                        > > for
                        > > > > TVM_GETITEM, passing in the handle to the root node as the
                        place
                        > > to
                        > > > > start the search, and the text that you are looking for
                        under
                        > > the root
                        > > > > node. If you send in more then one string to search for (eg
                        > > > > "Desktop|My Documents"), it will break it into parts and
                        send the
                        > > > > first part. If it finds it, great...it will return the
                        handle
                        > > to the
                        > > > > item. Or if you've passed in something like "Desktop|My
                        > > Documents",
                        > > > > it will call itself recursively for the next item in the
                        path
                        > > that you
                        > > > > want, passing in the handle to the item it just found
                        > > ("Desktop"). If
                        > > > > it doesn't find anything, it will return 0. That's why the
                        root
                        > > node
                        > > > > is selected but not highlighted when it can't find
                        > > anything...it's
                        > > > > trying to select the item with the handle of 0, which
                        doesn't
                        > > exist.
                        > > > > In your example program, the first call to
                        SelTreeViewItemPath
                        > > > > (SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                        > > Pictures");)
                        > > > > will always fail because you're not sending in the proper
                        path.
                        > > The
                        > > > > path should start off with Desktop since that's the root
                        node.
                        > > The
                        > > > > next 2 worked for me when I ran the program though. And the
                        > > last call
                        > > > > just selected (but not highlighted) the Desktop again,
                        because it
                        > > > > couldn't find that path.
                        > > > >
                        > > > > The endless loop comes into play when TVPathWalk calls itself
                        > > > > recursively, AND you pass in a path where the last
                        selectable
                        > > item has
                        > > > > no children under it (eg "Desktop|My Documents|My Pictures|
                        > > (dgdf )").
                        > > > > So it comes in, checks to see if we've found the right path
                        to
                        > > this
                        > > > > point ("My Pictures", which is there), checks to see if you
                        > > given it
                        > > > > more parts under "My Pictures" to look for (you
                        have, "(dgdf )"),
                        > > > > checks to see if "My Pictures" actually has children (it
                        > > > > doesn't)...and that's where the bug is. $hItem does not
                        equal
                        > > 0, it
                        > > > > equals the handle to the "My Pictures" node. Since there
                        are
                        > > more
                        > > > > parts to look for but no children under "My Pictures", it
                        will
                        > > > > continuously check "My Pictures" looking for children that
                        it
                        > > will
                        > > > > never find. Change that last call to look for "Desktop|My
                        > > > > Documents|My Pictures|(dgdf )", and you'll have your endless
                        > > loop.
                        > > > >
                        > > > > Brent
                        > > > >
                        > > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell"
                        <maxquig@>
                        > > wrote:
                        > > > > >
                        > > > > > I will gladly report this in source forge when I am able
                        to
                        > > > > > duplicate it in an application that others can run.
                        > > > > >
                        > > > > > I tried to reproduce the bug with this script that opens
                        > > Windows
                        > > > > > Explorer and tries to select some items on the left
                        TreeView.
                        > > > > >
                        > > > > > I get different problems this time. It does not duplicate
                        the
                        > > > > > endless loop. Instead, SelTreeViewItemPath() fails to
                        select
                        > > > > > anything but the root node, and even then it doesn't
                        highlight
                        > > the
                        > > > > > selected item.
                        > > > > >
                        > > > > > On the application that I'm testing, items on the tree are
                        > > selected
                        > > > > > and highlighted. The Endless loop happens when I
                        intentionally
                        > > try
                        > > > > > to select an item that doesn't exist in the "folders" that
                        do
                        > > exist.
                        > > > > >
                        > > > > > #!perl -w
                        > > > > >
                        > >
                        #####################################################################
                        > > > > > ##
                        > > > > > # EndlessLoopBug.pl Tim Mitchell July 13 2006
                        > > > > > #
                        > > > > > # Win32-GuiTest script attempting to reproduce a bug in
                        > > > > > SelectTargetTreeItem,
                        > > > > > # This script opens Windows Explorer
                        > > > > >
                        > >
                        #####################################################################
                        > > > > > ##
                        > > > > > use Win32::GuiTest qw(:ALL);
                        > > > > >
                        > > > > > system("start C:\\WINDOWS\\explorer.exe");
                        > > > > > sleep 1; #Wait for Windows\Explorer to get started
                        > > > > > # Explorer opens by default on My Documents folder
                        > > > > > # with "My Documents" in the title bar.
                        > > > > > #Finding the handle of the TreeView
                        > > > > > my @ExplorerWindow = FindWindowLike(undef, "My Documents");
                        > > > > > my @OuterFrame = FindWindowLike($ExplorerWindow
                        > > [0], "", "BaseBar");
                        > > > > > my @InnerFrame = FindWindowLike($OuterFrame
                        [0], "", "BaseBar");
                        > > > > > my @TreeWindow = FindWindowLike($InnerFrame
                        > > [0], "", "SysTreeView32");
                        > > > > > # Watch eplorer while this runs. It starts on My Documents
                        > > > > > sleep 3;
                        > > > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                        > > Pictures");
                        > > > > > # Nothing changed. My Pictures was NOT selected
                        > > > > > sleep 3;
                        > > > > > SelTreeViewItemPath($TreeWindow[0], "Desktop");
                        > > > > > # Desktop was selected but not highlighted in the tree
                        > > > > > sleep 3;
                        > > > > > SelTreeViewItemPath($TreeWindow[0], "Desktop|My
                        Documents|My
                        > > > > > Pictures");
                        > > > > > # Desktop is still selected but not highlighted
                        > > > > > sleep 3;
                        > > > > > SelTreeViewItemPath($TreeWindow[0], "My Documents|My
                        Pictures
                        > > > > > (dgdf )");
                        > > > > > # Makes not difference
                        > > > > > --- In perlguitest@yahoogroups.com, "Piotr Kaluski"
                        > > <pkaluski@>
                        > > > > > wrote:
                        > > > > > >
                        > > > > > > Can you create a bug report in source forge? Please
                        provide
                        > > a
                        > > > > > > description how to reproduce this bug quickly
                        > > > > > > --Piotr
                        > > > > > >
                        > > > > > > --- In perlguitest@yahoogroups.com, "Tim Mitchell"
                        > > <maxquig@>
                        > > > > > wrote:
                        > > > > > > >
                        > > > > > > > Bug to report...
                        > > > > > > >
                        > > > > > > > SelTreeViewItemPath gets stuck in endless loop if the
                        item
                        > > you
                        > > > > > are
                        > > > > > > > trying to select doesn't exist on the tree. This
                        function
                        > > needs
                        > > > > > to
                        > > > > > > > return a boolean result indicating success or failure.
                        > > > > > > >
                        > > > > > > > I tried to use it to verify that an item does not
                        exist on
                        > > the
                        > > > > > tree.
                        > > > > > > >
                        > > > > > > > Tim Mitchell
                        > > > > > > >
                        > > > > > >
                        > > > > >
                        > > > >
                        > > >
                        > >
                        >
                      • brentje
                        I actually forgot all about this. I just took at look at the GuiTest.PM file, and the only difference I see between my code and GuiTest is that GuiTest is
                        Message 11 of 11 , Feb 22, 2007
                        • 0 Attachment
                          I actually forgot all about this. I just took at look at the
                          GuiTest.PM file, and the only difference I see between my code and
                          GuiTest is that GuiTest is using Carp and I don't. Mine just returns
                          0, and I handle logging elsewhere. It also looks like Carp is only
                          used in that function, so I'm going to guess it's something to do with
                          Carp.

                          --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@...> wrote:
                          >
                          > Piotr,
                          >
                          > Sorry I took so long in testing this. The good news is that
                          > SelTreeViewItemPath no longer gets stuck in an endless loop when the
                          > item is not found on the tree. The bad news is that it doesn't
                          > return a flag of any kind to indicate whether or not it is
                          > successful. If not successfule it gives an error message "No such
                          > child SubsetsXXX at C:/Perl/site/lib/SMTpats/TKS.pm line 1579". In
                          > this example line 1579 is the line that calls the function.
                          >
                          > Tim
                        Your message has been successfully submitted and would be delivered to recipients shortly.