Win32::GuiTest::Treeview module is not able to fetch the text of the tree node for Windows 64 bit application. Here in this module there is a function GetItemText() output blank for the child nodes. Please see the small demo script. Please help me out if anybody have any idea otherwise we will have to move on to some other technology for 64 bit application. Thanks.

use warnings; use Win32::GuiTest qw(:ALL); use Win32::GuiTest::TreeView; use Data::Dumper; use Win32; # Get the handle of window object my @SEHandle = FindWindowLike(undef,$Title,'SysTreeView32','32783',und +ef); if (!$SEHandle[0]) { return 0; } sleep 2; # Find the number of child handles and store in an array my @ChildTree = Win32::GuiTest::TreeView::GetChildList_H($SEHandle[0]) +; Win32::MsgBox("@ChildTree"); foreach my $Child (@ChildTree) { my $Text = Win32::GuiTest::TreeView::GetItemText($SEHandle[0],$Chi +ld); Win32::MsgBox("Text = $Text"); }

I have downloaded TreeView.pm from google and added this module in GuiTest directory of perl64. Please see the code of GetItemText in Treeview.pm.

use strict; use Carp; use Win32; use Win32::GuiTest; use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw( GetSelItem_H GetFirstChild_H GetChildList_H GetNextSibling_H GetParent_H GetRoot_H SelItem ExpandItem IsVisible GetItemText GetItemRec HasChildren GetBuildTree_H ); # no need to export these function since they're no good to other (__I + think :)__) our @EXPORT_FAIL = qw( BuildTree_H TV_FIRST TVM_GETITEMRECT TVM_GETNEXTITEM TVM_GETITEMSTATE TVM_SELECTITEM TVM_EXPAND TVM_GETITEM TVGN_ROOT TVGN_NEXT TVGN_PREVIOUS TVGN_PARENT TVGN_CHILD TVGN_NEXTVISIBLE TVGN_PREVIOUSV +ISIBLE TVGN_CARET TVIS_EXPANDED TVIF_CHILDREN TVIF_TEXT TVE_EXPAND ); #************************* Def TV MSG Values ************************* +# #TV Values; sub TV_FIRST { 0x1100 } #TVM Flags sub TVM_GETITEMRECT { 0x1100 + 4 } sub TVM_GETNEXTITEM { 0x1100 + 10 } sub TVM_GETITEMSTATE { TV_FIRST() + 39 } sub TVM_SELECTITEM { TV_FIRST() + 11 } sub TVM_EXPAND { TV_FIRST() + 2 } sub TVM_GETITEM { TV_FIRST() + 12 } sub TVM_ENSUREVISIBLE { TV_FIRST() + 20 } #TVM_GETNEXTITEM Message flag: sub TVGN_ROOT { 0x0000 } sub TVGN_NEXT { 0x0001 } sub TVGN_PREVIOUS { 0x0002 } sub TVGN_PARENT { 0x0003 } sub TVGN_CHILD { 0x0004 } sub TVGN_NEXTVISIBLE { 0x0006 } sub TVGN_PREVIOUSVISIBLE { 0x0007 } sub TVGN_CARET { 0x0009 } sub TVIS_EXPANDED { 0x0020 } sub TVIF_CHILDREN { 0x0040 } sub TVIF_TEXT { 0x0001 } sub TVE_EXPAND { 0x0002 } ##============================================================ ## my $text = GetItemText($Tree_hwnd,$hItem) ## This function will require $Tree_hwnd; ## if $hItem is not provided, will return $text of the selected item. #============================================================ sub GetItemText { my $Tree_hwnd = shift; my $hItem = shift || GetSelItem_H($Tree_hwnd); Carp::croak('usage: GetItemText($Tree_hwnd)') unless defined($Tree +_hwnd); my $tvitem = Win32::GuiTest::AllocateVirtualBuffer( $Tree_hwnd, +128 ); my $text_buf = Win32::GuiTest::AllocateVirtualBuffer( $Tree_hwnd, +128 ); my $str_buf = pack( "L L L L L L L L L L", TVIF_TEXT(), #UINT mask; $hItem, #HTREEITEM hItem; 0, #UINT state; 0, #UINT stateMask; $text_buf->{'ptr'}, #LPTSTR pszText; 128, #int cchTextMax; 0, #int iImage; 0, #int iSelectedImage; 0, #int cChildren; 0, #LPARAM lParam; ); Win32::GuiTest::WriteToVirtualBuffer( $tvitem, $str_buf ); Win32::GuiTest::SendMessage( $Tree_hwnd, TVM_GETITEM(), 0, $tvitem +->{'ptr'} ); my $text = Win32::GuiTest::ReadFromVirtualBuffer( $text_buf, 128 ) +; $text =~ s/\0//g; Win32::GuiTest::FreeVirtualBuffer($tvitem); Win32::GuiTest::FreeVirtualBuffer($text_buf); return undef unless defined $text; return $text; } #-========================================================== ## my $hItem = GetSelItem_H($Tree_hwnd) ## This function require the TreeView control hwnd. ## Return selected item of the tree_control #============================================================ sub GetSelItem_H { my $Tree_hwnd = shift; Carp::croak('usage: GetSelItem_H($Tree_hwnd)') unless defined($Tre +e_hwnd); my $hItem = Win32::GuiTest::SendMessage( $Tree_hwnd, TVM_GETNEXTIT +EM(), TVGN_CARET(), 0 ); return undef unless defined $hItem; return $hItem; }

Link from where I have downloaded TreeView.pm module but this link currently not exist but you can see the mail. http://tech.groups.yahoo.com/group/perlguitest/message/1687


In reply to Problem in getting text of the tree node using Win32::GuiTest::Treeview for Windows 64 bit application by nsharma

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



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