Jump to content

my For...Next loop is being infinate?


layer
 Share

Recommended Posts

hey folks, could someone explain to me why this loop hapens for ever?!?!?!? :)

Func Generate ()
        $read= GUICtrlRead ($char)
        GUICtrlSetLimit ($pw, $read)
        For $i = $read to 1 Step -1
            $pass= Chr(Random(Asc("a"), Asc("z"), 1))
            Next
        GuictrlSetData ($pw, $pass, 1)
        ControlClick ("Random Generator", "Make", $make, "left", 1)
    EndFunc

it seems the contolclick never stops... please help

thanks

-layer o ney ney o:)

EDIT: and removing the ControlClick... when the number is generated, that just keeps doing numbers and skips the letters :):lmao:

Edited by layer
FootbaG
Link to comment
Share on other sites

#include <GUIConstants.au3>
GUICreate ("Random Generator", 200, 100)
GUISetState ()
$char= GUICtrlCreateInput ("# of characters outputted", 10, 20, 140)
$make= GUICtrlCreatebutton ("Make", 10, 60)
$pw= GUICtrlCreateEdit ("", 70, 63.5, 125, 20, $ES_READONLY)
GUICtrlCreateLabel ("Output:", 135, 40)
GUICtrlSetState ($char, $GUI_FOCUS)
Send ("^a")
While 1
    $get= GUIGetMsg ()
    If $get= $make then Generate ()
        If $get= -3 then Exit
    WEnd
    
    Func Generate ()
        $read= GUICtrlRead ($char)
        GUICtrlSetLimit ($pw, $read)
        For $i = $read to 1 Step -1
            $pass= Chr(Random(Asc("a"), Asc("z"), 1))
            Next
        GuictrlSetData ($pw, $pass, 1)
        ControlClick ("Random Generator", "Make", $make, "left", 1)
    EndFunc

FootbaG
Link to comment
Share on other sites

HAHA stupid me....

#include <GUIConstants.au3>
GUICreate ("Random Generator", 200, 100)
GUISetState ()
$char= GUICtrlCreateInput ("# of characters outputted", 10, 20, 140)
$make= GUICtrlCreatebutton ("Make", 10, 60)
$pw= GUICtrlCreateEdit ("", 70, 63.5, 125, 20, $ES_READONLY)
GUICtrlCreateLabel ("Output:", 135, 40)
GUICtrlSetState ($char, $GUI_FOCUS)
Send ("^a")
While 1
    $get= GUIGetMsg ()
    If $get= $make then 
        Generate ()
        ControlClick ("Random Generator", "Make", $make, "left", 1)
        EndIf
        If $get= -3 then Exit
    WEnd
    
    Func Generate ()
        $read= GUICtrlRead ($char)
        GUICtrlSetLimit ($pw, $read)
        For $i = $read to 1 Step -1
            $pass= Chr(Random(Asc("a"), Asc("z"), 1))
            Next
        GuictrlSetData ($pw, $pass, 1)
    EndFunc

:lmao: thanks CS

FootbaG
Link to comment
Share on other sites

Fixed.

#include <GUIConstants.au3>
GUICreate ("Random Generator", 200, 100)
$char= GUICtrlCreateInput ("# of characters outputted", 10, 20, 140)
$make= GUICtrlCreatebutton ("Make", 10, 60)
$pw= GUICtrlCreateEdit ("", 70, 63.5, 125, 20, $ES_READONLY)
GUICtrlCreateLabel ("Output:", 135, 40)
GUISetState ()
GUICtrlSetState ($char, $GUI_FOCUS)
While 1
   $get= GUIGetMsg ()
   If $get= $make then
      Generate ()
   EndIf
   If $get= -3 then Exit
WEnd
    
Func Generate ()
   $read= GUICtrlRead ($char)
   If NOT StringIsDigit($read) Then Return
   $read= Number($read)
   GuictrlSetData ($pw, "")
   GUICtrlSetLimit ($pw, $read)
   For $i = 1 To $read
      $pass= Chr(Random(Asc("a"), Asc("z"), 1))
      GuictrlSetData ($pw, $pass, 1)
   Next
EndFunc
Edited by SlimShady
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...