CODICE
#include <GuiConstants.au3>
#include <File.au3>
$MainGui = GUICreate("Character Counts", Default, 300)
$LTitle = GUICtrlCreateLabel("Character Counts", 80, 10, 400, 20)
$IFile = GUICtrlCreateInput("", 5, 40, 280, 20)
$BFile = GUICtrlCreateButton("Sfoglia", 290, 38, 105, 25)
$EText = GUICtrlCreateEdit("", 5, 70, 385, 150)
$BStart = GUICtrlCreateButton("Start", 5, 230, 390, 25)
$PLoading = GUICtrlCreateProgress(5, 262, 390, 15)
$LLoading = GUICtrlCreateLabel("0%", 190, 278, 390, 15)
GUISetState(@SW_SHOW)
GUICtrlSetFont($LTitle, 12, 800, 2, "VIRTUAL DJ")
GUICtrlSetColor($LTitle, 0x000000)
GUICtrlSetState($IFile, $GUI_Disable)
GUICtrlSetFont($BStart, 12, 800, 2, "Comic Sans MS")
GUICtrlSetFont($LLoading, 10, 800, 2, "Comic Sans MS")
While 1
$PercorsoFile = GUICtrlRead($IFile)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $BFile
$PercorsoFile = FileOpenDialog("Seleziona un file", @DesktopDir, "All Files (*.*)")
If Not @error Then GUICtrlSetData($IFile, $PercorsoFile)
$Read = FileRead($PercorsoFile)
If $Read <> "" Then GUICtrlSetData($EText, $Read)
Case $BStart
If $PercorsoFile <> "" Then
GUICtrlSetState($EText, $GUI_Disable)
Else
GUICtrlSetData($EText, "Selezionare un file!")
EndIf
Global $TotChar = 0, $MinChar = 0
For $i = _FileCountLines($PercorsoFile) to 1 Step -1
$CurrentLine = FileReadLine($PercorsoFile, $i)
$TotChar += StringLen($CurrentLine)
GUICtrlSetData($PLoading, 1 * 100 / $i)
GUICtrlSetData($LLoading, Round(1 * 100 / $i) & "%")
Next
$TotRighe = _FileCountLines($PercorsoFile)
Sleep(500)
GUICtrlSetData($EText, "-------------------------------------------Analisi file completata!------------------------------------------" & @CRLF & @CRLF & _
"Numero righe: " & $TotRighe & @CRLF & "Numero caratteri: " & $TotChar & @CRLF & @CRLF & _
"-------------------------------------------------------Testo:-------------------------------------------------------" & @CRLF & @CRLF & $Read)
GUICtrlSetState($EText, $GUI_Enable)
EndSwitch
WEnd