#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=..\icon图标.ico
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <array.au3>
#include <file.au3>
#include <CoProc.au3> ;多进程udf
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiToolBar.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("小鹤码表比对器", 380, 220,492, 124)
$Label1 = GUICtrlCreateLabel("请选择旧码表:", 16, 16, 116, 24)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 64, 40, 233, 25)
$Button1 = GUICtrlCreateButton("选择文件", 304, 40, 57, 25)
$Input2 = GUICtrlCreateInput("", 64, 112, 233, 25)
$Button2 = GUICtrlCreateButton("选择文件", 304, 112, 57, 25)
$Button3 = GUICtrlCreateButton("开始比较", 72, 152, 225, 41)
$Label2 = GUICtrlCreateLabel("请选择新码表:", 16, 85, 116, 24)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("已比对0行数据", 95, 200, 300, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("", 346, 200, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
TraySetState();只显示主进程图标
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $file1=FileOpenDialog("请选择文件",@DesktopDir,"文本文件 (*.txt)" )
If @error Then
MsgBox(0,"","请重新选择!")
Else
GUICtrlSetData($Input1,$file1)
EndIf
Case $Button2
Local $file2=FileOpenDialog("请选择文件",@DesktopDir,"文本文件 (*.txt)" )
If @error Then
MsgBox(0,"","请重新选择!")
Else
GUICtrlSetData($Input2,$file2)
EndIf
Case $Button3
Local $pd1=GUICtrlRead($input1),$pd2=GUICtrlRead($input2)
If $pd1<>"" And $pd2<>"" Then
Global $pidmain=_CoProc("main",$Form1&"|"&$pd1&"|"&$pd2&"|"&$Label3&"|"&$Label4);调用主进程变量的方法
Global $pidtime=_CoProc("time",$Form1&"|"&$Label4)
_CloseHandle($pidmain)
_CloseHandle($pidtime)
Else
MsgBox(0,"提示","请选择文件!")
EndIf
EndSwitch
WEnd
Func main($sParam)
;MsgBox(0,"",$sParam)
$aParam = StringSplit($sParam, "|")
$hWnd = HWnd($aParam[1])
Local $txt1=FileOpen($aParam[2])
Local $txt2=FileOpen($aParam[3])
Local $num,$a=1
Local $array[$a][2];存放对比数据
Local $readline1=_FileCountLines($aParam[2])
Local $readline2=_FileCountLines($aParam[3])
If $readline1 > $readline2 Then
Local $count=$readline1
Else
$count=$readline2
EndIf
For $num=1 To $count
Local $line1,$line2
$line1=FileReadLine($txt1,$num)
$line2=FileReadLine($txt2,$num)
If $line1<>$line2 Then
ReDim $array[$a][2]
$array[$a-1][0]=$line1
$array[$a-1][1]=$line2
$a+=1
EndIf
If Mod($num,1000)=0 Then
ControlSetText($hWnd, '', Number($aParam[4]),"共"&$count&"行,"&"已比对"&$num&"行数据")
EndIf
If $num=$count Then
ControlHide($hWnd,"",Number($aParam[5]))
EndIf
Next
FileClose($txt1)
FileClose($txt2)
_ArrayDisplay($array)
EndFunc
Func time($time)
$time = StringSplit($time, "|")
$n1 =Number($time[2]) ;$input1 的控件id
$hWnd1 = HWnd($time[1])
Local $fen,$sed,$min=0
While $sed>=0
$sed+=1
If $sed=60 Then
$sed=0
$min+=1
EndIf
If $min<10 Then
$fen="0"&$min
Else
$fen=$min
EndIf
If $sed<10 Then $sed="0"&$sed
ControlSetText($hWnd1, '', Number($time[2]),$fen&":"&$sed)
Sleep(1000)
WEnd
EndFunc
文本模式如下