| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Win32::AutoItX::Control::TreeView; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Win32::AutoItX::Control::TreeView - OO interface for TreeView32 controls |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Win32::AutoItX; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $a = Win32::AutoItX->new; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $pid = $a->Run('regedit.exe'); |
|
14
|
|
|
|
|
|
|
my $window = $a->get_window('Registry Editor'); |
|
15
|
|
|
|
|
|
|
$window->wait; |
|
16
|
|
|
|
|
|
|
$window->show; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $treeview = $window->get_control('SysTreeView321')->treeview(); |
|
19
|
|
|
|
|
|
|
$treeview->expand('#0'); |
|
20
|
|
|
|
|
|
|
for my $i (0 .. $treeview->count('#0') - 1) { |
|
21
|
|
|
|
|
|
|
print "Item #$i = ", $treeview->text("#0|#$i"), "\n"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$treeview->expand('Computer|HKEY_LOCAL_MACHINE'); |
|
25
|
|
|
|
|
|
|
$treeview->select('Computer|HKEY_LOCAL_MACHINE|SOFTWARE'); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Win32::AutoItX::Control::TreeView provides an object-oriented interface for |
|
30
|
|
|
|
|
|
|
AutoItX methods to operate with TreeView32 (SysTreeView32) controls. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The C<$item> parameter is a string-based parameter that is used to reference a |
|
33
|
|
|
|
|
|
|
particular treeview item using a combination of text and indices. Indices are |
|
34
|
|
|
|
|
|
|
0-based. For example: |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Heading1 |
|
37
|
|
|
|
|
|
|
----> H1SubItem1 |
|
38
|
|
|
|
|
|
|
----> H1SubItem2 |
|
39
|
|
|
|
|
|
|
----> H1SubItem3 |
|
40
|
|
|
|
|
|
|
----> ----> H1S1SubItem1 |
|
41
|
|
|
|
|
|
|
Heading2 |
|
42
|
|
|
|
|
|
|
Heading3 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Each "level" is separated by |. An index is preceded with #. |
|
46
|
|
|
|
|
|
|
For example: |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Item $item |
|
49
|
|
|
|
|
|
|
Heading2 "Heading2" or "#1" |
|
50
|
|
|
|
|
|
|
H1SubItem2 "Heading1|H1SubItem2" or "#0|#1" |
|
51
|
|
|
|
|
|
|
H1S1SubItem1 "Heading1|H1SubItem3|H1S1SubItem1" or "#0|#2|#0" |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
56
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
61
|
1
|
|
|
1
|
|
4
|
use Scalar::Util qw{ blessed }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
55
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
|
5
|
use overload fallback => 1, '""' => sub { $_[0]->{control}->{control} }; |
|
|
1
|
|
|
0
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
0
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my %Control_Commands = qw{ |
|
66
|
|
|
|
|
|
|
count GetItemCount |
|
67
|
|
|
|
|
|
|
exists Exists |
|
68
|
|
|
|
|
|
|
text GetText |
|
69
|
|
|
|
|
|
|
is_checked IsChecked |
|
70
|
|
|
|
|
|
|
check Check |
|
71
|
|
|
|
|
|
|
uncheck Uncheck |
|
72
|
|
|
|
|
|
|
collapse Collapse |
|
73
|
|
|
|
|
|
|
expand Expand |
|
74
|
|
|
|
|
|
|
select Select |
|
75
|
|
|
|
|
|
|
selected GetSelected |
|
76
|
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 METHODS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 new |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$treeview = Win32::AutoItX::Control::TreeView->new($control) |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
creates a TreeView object. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub new { |
|
89
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
90
|
0
|
|
|
|
|
|
my %self; |
|
91
|
0
|
|
|
|
|
|
$self{control} = shift; |
|
92
|
|
|
|
|
|
|
croak "The first argument should be a Win32::AutoItX::Control object" |
|
93
|
|
|
|
|
|
|
unless blessed $self{control} |
|
94
|
0
|
0
|
0
|
|
|
|
and $self{control}->isa('Win32::AutoItX::Control'); |
|
95
|
0
|
|
|
|
|
|
return bless \%self, $class; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 count |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$count = $treeview->count($item) |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
returns the number of children for a selected item. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 exists |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$boolean = $treeview->exists($item) |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
returns 1 if an item exists, otherwise 0. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 text |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$text = $treeview->text() |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
returns the text of an item. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 is_checked |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$checked = $treeview->is_checked($item) |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
returns the state of an item. 1:checked, 0:unchecked, -1:not a checkbox. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 check |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$treeview->check($item) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
checks an item (if the item supports it). |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 uncheck |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$treeview->uncheck($item) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
unchecks an item (if the item supports it). |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 collapse |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$treeview->collapse($item) |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
collapses an item to hide its children. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 expand |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$treeview->expand($item) |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
expands an item to show its children. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 select |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$treeview->select($item) |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
selects an item. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 selected |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$item = $treeview->selected($use_index) |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
returns the item reference of the current selection using the text reference of |
|
158
|
|
|
|
|
|
|
the item (or index reference if C<$use_index> is set to 1). |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 Win32::AutoItX::Control methods |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This module also provides most of L methods. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
167
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
168
|
0
|
|
|
|
|
|
my $method = our $AUTOLOAD; |
|
169
|
0
|
|
|
|
|
|
$method =~ s/.*:://; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my @params = @_; |
|
172
|
0
|
0
|
|
|
|
|
if (exists $Control_Commands{$method}) { |
|
173
|
0
|
0
|
|
|
|
|
push @params, '' unless @params; |
|
174
|
0
|
0
|
|
|
|
|
push @params, '' if @params < 2; |
|
175
|
0
|
|
|
|
|
|
unshift @params, $Control_Commands{$method}; |
|
176
|
0
|
|
|
|
|
|
$method = 'ctw'; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
0
|
|
|
|
|
|
$self->{control}->$method(@params); |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=over |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item L |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item L |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item AutoItX Help |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item https://www.autoitscript.com/autoit3/docs/functions/ControlTreeView.htm |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Mikhail Telnov EMikhail.Telnov@gmail.comE |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Mikhail Telnov. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This library is free software; you may redistribute and/or modify it |
|
205
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1; |