As title say i have next problem
Script need to works like this :
1. Open file (works)
2. When pressed start button, update status (works)
3. Need to count how many passwords are created (works) *FIXED
4. Need to loop all time when i press Start until i press Stop button (dont works)
Updated :
now script works it loop all time i edited it, but i cant drop it with Stop button, only shut it down in try icon....... :(
Whole script
Updated - help guys :( :( :(
Script need to works like this :
1. Open file (works)
2. When pressed start button, update status (works)
3. Need to count how many passwords are created (works) *FIXED
4. Need to loop all time when i press Start until i press Stop button (dont works)
Updated :
now script works it loop all time i edited it, but i cant drop it with Stop button, only shut it down in try icon....... :(
Whole script
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 483, 178, 201, 137)
$Group1 = GUICtrlCreateGroup("File path", 8, 8, 465, 65)
$browse = GUICtrlCreateButton("Browse", 24, 32, 75, 25)
$filePath = GUICtrlCreateLabel("", 112, 36, 346, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Passwords created", 8, 80, 465, 57)
$passwordsCreated = GUICtrlCreateLabel("", 24, 104, 430, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$startBtn = GUICtrlCreateButton("Start", 8, 144, 75, 25)
$stopBtn = GUICtrlCreateButton("Stop", 88, 144, 75, 25)
$status = GUICtrlCreateLabel("Idle", 415, 151, 57, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $file, $filePath
Global $IsPaused = 1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $browse
; browse for file and put it in label too see path
$file = FileOpenDialog("Open file to write passwords", "", "(*.txt)", "1")
GUICtrlSetData($filePath, $file)
Case $startBtn
; if file isn't opened
If $file == "" Then
MsgBox(48, "Error", "Please choose file to write in!")
Else
$IsPaused = -1
GUICtrlSetData($status, "Running")
; this need to loop until STOP button is pressed
;For $i = 1 To 99
Do
If $IsPaused = -1 Then
FileWrite($file, _RandomPassword(10) & @CRLF) ; write to file
$countLines = _FileCountLines($file) ; count lines in file
GUICtrlSetData($passwordsCreated, $countLines) ; update passwords filed
EndIf
Until False
;Next
EndIf
Case $stopBtn
_stop()
EndSwitch
WEnd
; function to generate random passwords
Func _RandomPassword($length)
$text = ""
For $i = 1 To $length
$text &= Chr(Random(65, 90, 1))
Next
Return $text
EndFunc
; function to stop executing script
Func _stop()
$IsPaused = 1
GUICtrlSetData($status, "Stoped")
EndFunc