Class: AutoItX3::ListView
Overview
A list view is a list which can contain many different columns of data. For example, the Windows Explorer uses this control.
Constant Summary collapse
- LIST =
Ordinary list view
"list"
- DETAILS =
Detailed view
"details"
- SMALL_ICONS =
View with small icons
"smallicons"
- LARGE_ICONS =
View with large icons
"largeicons"
Instance Method Summary collapse
-
#change_view(view) ⇒ Object
Changes the view of
self
. -
#clear_selection ⇒ Object
(also: #select_none)
AutoItX3::ListView#clear_selection ==> nil AutoItX3::ListView#select_none ==> nil.
-
#deselect(from, to = "") ⇒ Object
Deselects the given item(s).
-
#find(string, sub_item = "") ⇒ Object
Searches for
string
andsub_item
inself
. -
#invert_selection ⇒ Object
Inverts the selection.
-
#item_count ⇒ Object
(also: #size, #length)
call-seq: item_count ==> anInteger size ==> anInteger length ==> anInteger.
-
#num_selected ⇒ Object
Returns the number of selected items.
-
#num_subitems ⇒ Object
Returns the number of subitems in
self
. -
#select(from, to = "") ⇒ Object
Selects the given item(s).
-
#select_all ⇒ Object
Selects all items in
self
. -
#selected ⇒ Object
Returns the inices of the selected items.
-
#selected?(item) ⇒ Boolean
Returns wheather or not
item
is selected. -
#send_command_to_list_view(command, arg1 = "", arg2 = "") ⇒ Object
Sends
cmd
toself
. -
#text_at(item, subitem = "") ⇒ Object
(also: #[])
call-seq: AutoItX3::ListView#text_at( item [, subitem ] ) ==> aString AutoItX3::ListView#[ item [, subitem ] ] ==> aString.
Methods inherited from Control
#click, #disable, #enable, #enabled?, #focus, from_control, functions, functions=, #handle, #hide, #initialize, #move, #rect, #send_command_to_control, #send_keys, #show, #text, #text=, #visible?
Constructor Details
This class inherits a constructor from AutoItX3::Control
Instance Method Details
#change_view(view) ⇒ Object
836 837 838 |
# File 'lib/AutoItX3/control.rb', line 836 def change_view(view) send_command_to_list_view("ViewChange", view) end |
#clear_selection ⇒ Object Also known as: select_none
809 810 811 |
# File 'lib/AutoItX3/control.rb', line 809 def clear_selection send_command_to_list_view("SelectClear") end |
#deselect(from, to = "") ⇒ Object
Deselects the given item(s).
Parameters
from
-
Either the index of the item to deselect or the start of the item list to deselect. 0-based.
to
-
(
""
) The end of the item list to deselect. 0-based.
Return value
Unknown.
Raises
- Au3Error
-
Control or window not found.
653 654 655 |
# File 'lib/AutoItX3/control.rb', line 653 def deselect(from, to = "") send_command_to_list_view("DeSelect", from, to) end |
#find(string, sub_item = "") ⇒ Object
Searches for string
and sub_item
in self
.
Parameters
string
-
The string to look for.
sub_item
-
(
""
) The “colum” to look in. A 0-based integer index.
Return value
Returns the index of the found list item or false if it isn’t found.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.find("file1.rb") #=> 3
p ctrl.find("15 KB", 3) #=> 2
p ctrl.find("nonexistant") #=> false
669 670 671 672 673 674 675 676 |
# File 'lib/AutoItX3/control.rb', line 669 def find(string, sub_item = "") res = send_command_to_list_view("FindItem", string, sub_item).to_i if res == -1 false else res end end |
#invert_selection ⇒ Object
Inverts the selection.
Return value
Unknown.
Raises
- Au3Error
-
Control or window not found.
Example
ctrl.invert_selection
Remarks
This works even if nothing or everything is selected.
823 824 825 |
# File 'lib/AutoItX3/control.rb', line 823 def invert_selection send_command_to_list_view("SelectInvert") end |
#item_count ⇒ Object Also known as: size, length
call-seq:
item_count ==> anInteger
size ==> anInteger
length ==> anInteger
Returns the number of items in self
.
Return value
The number of items in self
.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.item_count #=> 9
690 691 692 |
# File 'lib/AutoItX3/control.rb', line 690 def item_count send_command_to_list_view("GetItemCount").to_i end |
#num_selected ⇒ Object
Returns the number of selected items.
Return value
The number of items selected.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.num_selected #=> 3
714 715 716 |
# File 'lib/AutoItX3/control.rb', line 714 def num_selected send_command_to_list_view("GetSelectedCount").to_i end |
#num_subitems ⇒ Object
Returns the number of subitems in self
.
Return value
An integer that indicates how many “columns” the list view has.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.num_subitems #=> 4
725 726 727 |
# File 'lib/AutoItX3/control.rb', line 725 def num_subitems send_command_to_list_view("GetSubItemCount").to_i end |
#select(from, to = "") ⇒ Object
Selects the given item(s).
Parameters
from
-
The index where to start or the item to select. 0-based integer.
to
-
The index where to stop. 0-based integer.
Return value
Unknown.
Raises
- Au3Error
-
Control or window not found.
Example
ctrl.select(3)
ctrl.select(3, 5)
Remarks
This method doesn’t deselect anything. If you want an entire new selection, call #clear_selection before calling this method.
784 785 786 |
# File 'lib/AutoItX3/control.rb', line 784 def select(from, to = "") send_command_to_list_view("Select", from, to) end |
#select_all ⇒ Object
Selects all items in self
.
Return value
Unknown.
Raises
- Au3Error
-
Control or window not found.
Example
ctrl.select_all
795 796 797 |
# File 'lib/AutoItX3/control.rb', line 795 def select_all send_command_to_list_view("SelectAll") end |
#selected ⇒ Object
Returns the inices of the selected items.
Return value
An array containg the indices of the selected items which is empty if none is selected.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.selected #=> [3, 4, 5]
703 704 705 |
# File 'lib/AutoItX3/control.rb', line 703 def selected send_command_to_list_view("GetSelected", 1).split("|").map(&:to_i) end |
#selected?(item) ⇒ Boolean
Returns wheather or not item
is selected.
Parameters
item
-
The 0-based index of the item to check.
Return value
true or false.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.selected?(3) #=> false
p ctrl.selected?(7) #=> true
766 767 768 |
# File 'lib/AutoItX3/control.rb', line 766 def selected?(item) send_command_to_list_view("IsSelected", item).to_i == 1 end |
#send_command_to_list_view(command, arg1 = "", arg2 = "") ⇒ Object
Sends cmd
to self
. This method is only used internally.
636 637 638 639 640 641 642 643 |
# File 'lib/AutoItX3/control.rb', line 636 def send_command_to_list_view(command, arg1 = "", arg2 = "") Control.functions[__method__] ||= AU3_Function.new("ControlListView", 'SSSSSSPI') buffer = " " * BUFFER_SIZE buffer.wide! Control.functions[__method__].call(@title.wide, @text.wide, @c_id.wide, command.wide, arg1.to_s.wide, arg2.to_s.wide, buffer, BUFFER_SIZE - 1) raise(Au3Error, "Unknown error occured when sending '#{command}' to '#{@c_id}' in '#{@title}'! Maybe an invalid window?") if AutoItX3.last_error == 1 buffer.normal.strip end |
#text_at(item, subitem = "") ⇒ Object Also known as: []
call-seq:
AutoItX3::ListView#text_at( item [, subitem ] ) ==> aString
AutoItX3::ListView#[ item [, subitem ] ] ==> aString
Returns the text at the given position.
Parameters
item
-
The “row” to look in. 0-based integer.
subitem
-
(
""
) The “colum” to look in. 0-based integer.
Return value
The text at the given position.
Raises
- Au3Error
-
Control or window not found.
Example
p ctrl.text_at(2, 3) #=> "6 KB"
Remarks
Don’t make any assumptions about the encoding or event the content of a list box item. For example, a date field of the Windows Explorer comes out like this:
p ctrl.text_at(2, 1) #=> "ÔÇÄ10.ÔÇÄ05.ÔÇÄ2010 ÔÇÅÔÇÄ16:53"
which is probably not what you thought, since in the Explorer Window it’s presented as:
10.05.2010 16:52
751 752 753 |
# File 'lib/AutoItX3/control.rb', line 751 def text_at(item, subitem = "") send_command_to_list_view("GetText", item, subitem) end |