Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Problem in getting text of the tree node using Win32::GuiTest::Treeview for Windows 64 bit application

by nsharma (Initiate)
on Aug 23, 2012 at 07:57 UTC ( #989230=perlquestion: print w/ replies, xml ) Need Help??
nsharma has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Problem in getting text of the tree node using Win32::GuiTest::Treeview for Windows 64 bit application
Select or Download Code
Re: Problem using Win32::GuiTest::Treeview for Windows 64 bit application
by BrowserUk (Pope) on Aug 23, 2012 at 08:04 UTC
    I have downloaded TreeView.pm from google ...

    You'd be more likely to get help if you provided a link to this instead of a vague google reference that doesn't immediately turn up anything promising.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Hi, I have uploaded the TreeView.pm on my scratchpad. Please go through the module and let me know the solution as soon as possible. I am waiting for ur reply... Thanks.

        Please go through the module and let me know the solution as soon as possible.

        The solution to what?

        Have you identified a particular problem, or do you expect me to go through all 907 lines and find it for you as well?

        I am waiting for ur reply...

        Ur gna B w8ing a tiiiiiiiiiiiiiiiiiiiiiiiiiime.

        Life line

        If I understand the implications of your posts, you are saying that when you call a particular Win32::GuiTest function, with particular arguments, on 64-bit Windows, you aren't getting the result you expect.

        If that is the case, don't throw 1000 lines of code at me -- that I can't run without building an application, and won't demonstrate the problem unless I accidentally hit the exact scenario in which you are seeing failures. Can you not see that you will never get help that way?

        Think! Start from the point of known failure. Construct a script that recreates that failure:

        • simple: forget OO, forget tests, forget comment blocks, forget your uni/company/personal coding standards.

          You are not creating a work of art, nor a thesis project, nor a legacy for your children, nor an advertisement for your programming skills.

          Your responsibility is to demonstrate the problem as simply as possible.

        • short: 20 lines would be good. 100 lines is okay if they are all actually required.

          1000 lines is just taking the piss.

          Without getting silly and golfing, the fewer lines the better.

        • standalone: no modules or dependencies.

          Not even your personal favorite test::more::morestill::best::bestist::bestistButBetter::* test suite. I probably don't have; certainly don't want it; wouldn't trust it anyway, and won't install it.

          The easier it is for people to run your sample code, the more likely some of them are to try it.

          Throwing a 1000 line module, with no script that exercises it and no clear indication of the problem you've encountered, doesn't enable that.

        Make it easy for those you asking for (free) help. Normally, I would simply be ignoring your post, but you've obviously taken a lot of time and put in a lot of work.

        You've just expended it in the wrong place to enable anyone here to help you.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        pmsig

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://989230]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-08-30 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls