自己解决,重新写了一下代码,很乱,但批量导入还是不行,只有一个个的导,还有保存功能也不好用,只能调出保存窗口,不能保存,但可以直接在目录下生成明细文件
代码如下:#include <GUIConstants.au3>
;#include <ButtonConstants.au3>
;#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TXT文件合并 By CFXZ", 600, 433, 427, 173)
$Edit1 = GUICtrlCreateEdit("", 440, 50, 150, 360, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY, $WS_HSCROLL))
$Edit2 = GUICtrlCreateEdit("",30, 50, 400, 360,BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY, $WS_HSCROLL))
$Edit3 = GUICtrlCreateEdit("",520, 15, 70, 20,$ES_READONLY)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("请选择代码文件:", 22, 16, 120, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("代码个数共:", 430, 16, 90, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("浏 览", 150, 16, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$message = "浏览文件"
;$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
$sFile = FileOpenDialog($message, @WorkingDir, "文本文件 (*.txt)", 1 + 4)
_GUICtrlEdit_AppendText($Edit1, FileRead($sFile)) ;这个地方只能一个文本一个文本的添加
;WinActivate("合并TXT文件", "")
$var = ControlGetText("TXT文件合并 By CFXZ", "", "Edit1")
;MsgBox(4096,"",$var)
$file = FileOpen('hs.txt', 2 + 8)
FileWriteLine ($file,$var)
$a = FileGetLongName($sFile)
_GUICtrlEdit_AppendText($Edit2,$a & @LF)
;MsgBox(4096,"",$a)
$b = ControlCommand("TXT文件合并 By CFXZ", "", "Edit1", "GetLineCount", "")
_GUICtrlEdit_SetText($Edit3,$b-1)
;MsgBox(4096,"",$b)
;Case $Button2
;$message = "另存为"
;$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
;$sFile = FileSaveDialog($message, $MyDocsFolder, "文本文件 (*.txt)", 2)
EndSwitch
WEnd
|