本帖最后由 C.L 于 2010-8-10 02:12 编辑
以前写过的例子,给你参考,可以按Ctrl+鼠标多选,可以直接鼠标拖选,提取选中项目,请看ListView 部份:#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
;~ #include <array.au3>
#include <file.au3>
$Form1 = GUICreate("test", 400, 380, @DesktopWidth / 2 - 100, @DesktopHeight / 2 - 100)
$aStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$listview1 = GUICtrlCreateListView("名称", 0, 0, 398, 290, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview1, $aStyles)
_GUICtrlListView_SetView($listview1, "1")
GUICtrlSetBkColor($listview1, 0xffffff)
$button1 = GUICtrlCreateButton ("选定目标",200,330,100,30)
GUISetState(@SW_SHOW)
$curdir = FileSelectFolder ("选择目录","")
If StringRight ($curdir,1) <> "" Then $curdir &= ""
$folder = _FileListToArray($curdir, "*", 0)
If IsArray($folder) Then
For $i=0 To $folder[0]
$listteam = GUICtrlCreateListViewItem ($folder[$i],$listview1)
$attrib = FileGetAttrib ($curdir&$folder[$i])
If StringInStr($attrib, "D") Then
GUICtrlSetImage($listteam, "shell32.dll", 5)
Else
GUICtrlSetImage($listteam, "shell32.dll", 1)
EndIf
Next
WinSetTitle ("test","","test " & $curdir)
EndIf
While 1
$nMsg = GUIGetMsg ()
Switch $nMsg
Case -3
Exit
Case $button1
$totalnum = _GUICtrlListView_GetItemCount($listview1)
$selectcount = _GUICtrlListView_GetSelectedCount($listview1)
$out = ""
For $i = 0 To $totalnum-1
If $selectcount Then
If _GUICtrlListView_GetItemSelected($listview1, $i) == True Then
$val = _GUICtrlListView_GetItemTextString($listview1, $i)
$attrib = FileGetAttrib ($curdir&$val)
If StringInStr($attrib, "D") Then
$out &= $val&" 是目录"&@CRLF
Else
$out &= $val&" 是文件" & @CRLF
EndIf
EndIf
Else
$out = "没有选择文件"
EndIf
Next
MsgBox (0,"已选择的文件","当前的目录:"&$curdir & @CRLF & $out)
EndSwitch
WEnd
|