#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include-once
$Dir = "C:\Documents and Settings\Administrator\My Documents"
$Filelist = _FileListToArrayRec($Dir, "*.txt;*.xml", 1, 1, 0, 1)
Local $Item1[$Filelist[0]], $Item2[0]
GUICreate("文件选择", 720, 500)
$ListView1 = GUICtrlCreateListView("文件目录", 20, 30, 300, 400)
For $i = 0 To $Filelist[0] - 1
$Item1[$i] = GUICtrlCreateListViewItem($Filelist[$i + 1], $ListView1)
Next
$ListView2 = GUICtrlCreateListView("文件目录", 400, 30, 300, 400)
_GUICtrlListView_SetColumnWidth($ListView1, 0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($ListView2, 0, $LVSCW_AUTOSIZE_USEHEADER)
$Button1 = GUICtrlCreateButton("打开", 335, 190, 50)
GUISetState()
Global $str = '' ;//总字符串
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Item1[0] To $Item1[$Filelist[0] - 1]
If Not StringInStr($str, GUICtrlRead($nMsg)) Then
$str &= GUICtrlRead($nMsg) ;//累计字符串
ReDim $Item2[UBound($Item2) + 1]
$Item2[UBound($Item2) - 1] = GUICtrlCreateListViewItem(GUICtrlRead($nMsg), $ListView2)
EndIf
Case $Button1
For $i = 0 To UBound($Item2) - 1
Run("notepad.exe " & $Dir & StringTrimRight(GUICtrlRead($Item2[$i]), 1))
Next
Exit
EndSwitch
WEnd
也许有更好的方案 |