Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 10:53

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Need help with Random ganeration

Discussion on Need help with Random ganeration within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Need help with Random ganeration

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
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
Updated - help guys
mlukac89 is offline  
Old 02/09/2014, 17:27   #2
 
SpieleHacksInfo's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 448
Received Thanks: 278
Code:
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
		$nMsg = GUIGetMsg()
		Switch $nMsg
		        Case $stopBtn
			_stop()
		EndSwitch
Until $nMsg = $stopBtn
but on thing: stop <> paused
SpieleHacksInfo is offline  
Old 02/09/2014, 17:38   #3
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
This dont works too first of all wont start and then you press stop button it closes program, i need when i press start to start loop untill i press stop but not to shut it down if you know what i mean

Compile my code and look on what i mean
mlukac89 is offline  
Old 02/09/2014, 17:58   #4
 
SpieleHacksInfo's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 448
Received Thanks: 278
Quote:
Originally Posted by mlukac89 View Post
This dont works too first of all wont start and then you press stop button it closes program, i need when i press start to start loop untill i press stop but not to shut it down if you know what i mean

Compile my code and look on what i mean
lol then you do something wrong.
learn the basic first

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
Global $countLines = 0
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 == "" 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
						$countLines = $countLines + 1
						GUICtrlSetData($passwordsCreated, $countLines) ; update passwords filed
					EndIf
					$nMsg = GUIGetMsg()
					Switch $nMsg
						Case $stopBtn
			                _stop()
					EndSwitch
				Until $nMsg = $stopBtn
				;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
it wont help you learning this language if you asking for every little thing like loops
SpieleHacksInfo is offline  
Thanks
1 User
Old 02/09/2014, 18:11   #5
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Ok thx for tip but i still dont know why this must be in Do ... Until

Why dont works Do ... Until $IsPaused = 1 because that is function when you press Stop button, or Do ... Until $stopBtn

I know that it can be stoped with _IsPressed() function but you cant put variable in that function

This loops are too complicated

Code:
				Do
					If $IsPaused = -1 Then
						FileWrite($file, _RandomPassword(10) & @CRLF) ; write to file
						$countLines = _FileCountLines($file) ; count lines in file
						$countLines = $countLines + 1
						GUICtrlSetData($passwordsCreated, $countLines) ; update passwords filed
					EndIf
					$nMsg = GUIGetMsg() ; from here
					Switch $nMsg
						Case $stopBtn
			                _stop()
					EndSwitch ; to here
				Until $nMsg = $stopBtn
mlukac89 is offline  
Reply


Similar Threads Similar Threads
[Selling] 35 random acc 5€
02/07/2014 - League of Legends Trading - 3 Replies
Hi, i sell 35 random account for 5€ :)
[SALE] Random ISRO chars in random servers CHEAP, from 1$ to 3$
06/03/2012 - Silkroad Online Trading - 4 Replies
Hello, I want to sell all those chars very cheap for PayPal money from 1$ to 3$ , because I need some money to buy usb joystick to play FIFA on pc ^^ If you buy them all, I can sell all those chars for 15$!!! Contacts - skype: myntex2 I ACCEPT PAYPAL ONLY So let's start:
Random Box #2
05/11/2011 - WarRock - 9 Replies
Schönen Tag :) Es gibt ab sofort Random Box #2 ! Genau das Gleiche wie bei Random Box #1 drinn ! ( Nur gibt es bei Random Box #2 Famas Tactical, anstatt Silencer ) Hier von Facebook: Are you ready for 60 days of the Famas G2 Tactical???!!! Here is your chance to scratch & win with the Random Box #2! By popular demand, we are releasing our 2nd random box TODAY. Make sure to try your luck at the GamersFirst Marketplace right now!: Marketplace &ndash; Free2Play, MMO, Knight Online World, War...
i put this here at random
04/22/2008 - Say Hello - 0 Replies
hi all. I really have nothing better to do, so hi



All times are GMT +1. The time now is 10:54.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.