Sign in to follow this  
Followers 0
wander

Whats Wrong?

7 posts in this topic

Hi all, i tryed to add a func in a script but it got bugged. It starts and dissappears.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_icon=E:\test.ico
#AutoIt3Wrapper_outfile=Pass-Gen.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Fileversion=1.10
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Clipboard.au3>
Local $length, $letters, $Checkbox1, $Checkbox2, $Checkbox3, $Checkbox4, $Checkbox5
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Password Generator", 718, 387, 189, 120)
GUISetBkColor(0x808080)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Group2 = GUICtrlCreateGroup("Your Generated Password", 24, 200, 329, 105)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlCreateInput("", 40, 240, 281, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\password generator background.jpg", 352, 0, 364, 364, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("Generate", 24, 328, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Button2 = GUICtrlCreateButton("Reset all fields", 144, 328, 75, 25, 0)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Button3 = GUICtrlCreateButton("Close", 264, 328, 75, 25, 0)
GUICtrlSetOnEvent($Button3, "Button3Click")
$Group1 = GUICtrlCreateGroup("Options", 24, 16, 321, 177)
$lenght = GUICtrlCreateInput("", 216, 64, 121, 21)
$Label41 = GUICtrlCreateLabel("Lenght of the Password", 216, 40, 116, 17)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Checkbox1 = GUICtrlCreateCheckbox("Numbers", 48, 40, 97, 17)
GUICtrlSetOnEvent($Checkbox1, "Checkbox1Click")
$Checkbox2 = GUICtrlCreateCheckbox("Letters(small)", 48, 72, 97, 17)
GUICtrlSetOnEvent($Checkbox2, "Checkbox2Click")
$Checkbox3 = GUICtrlCreateCheckbox("Letters(BIG)", 48, 104, 97, 17)
GUICtrlSetOnEvent($Checkbox3, "Checkbox3Click")
$Checkbox4 = GUICtrlCreateCheckbox("Letters(small and BIG)", 48, 136, 121, 17)
GUICtrlSetOnEvent($Checkbox4, "Checkbox4Click")
$Checkbox5 = GUICtrlCreateCheckbox("Numbers, Letters,(BIG/small)  +Special Characters", 48, 168, 289, 17)
GUICtrlSetOnEvent($Checkbox5, "Checkbox5Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$genpw = GUICtrlCreateInput("", 40, 240, 281, 21)
$filemenu = GUICtrlCreateMenu("File")
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$aboutmenu = GUICtrlCreateMenu("About")
$aboutitem = GUICtrlCreateMenuItem("Credits", $aboutmenu)
GUISetState(@SW_SHOW)
Global $exititem, $aboutitem
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $nMsg = $exititem
                Exit

        Case $nMsg = $aboutitem
                About()
    EndSwitch
WEnd

Func About()
$Form1 = GUICreate("About", 487, 357, 289, 176)
GUISetIcon("D:\006.ico")
GUISetBkColor(0xA0A0A4)
$Button11 = GUICtrlCreateButton("&OK", 192, 320, 75, 25)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\password generator background.jpg", 0, 0, 484, 172, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Product Name : Password Generator made by Wander(a.k.a Crowen, and Виктор Бакърджиев)", 0, 216, 460, 17)
$Label2 = GUICtrlCreateLabel("Password Generator Info", 152, 176, 210, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Version : 1.10", 0, 240, 69, 17)
$Label4 = GUICtrlCreateLabel("Password Generator is a tool wich you use to generate Random Passwords with numbers and letters ", 0, 264, 478, 17)
$Label5 = GUICtrlCreateLabel("At Version 1.10: Special Characters included", 0, 296, 214, 17)
GUICtrlSetBkColor(-1, 0x008080)
GUISetState(@SW_SHOW)

While 45
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button11
            ExitLoop
    EndSwitch
WEnd
EndFunc



Func Button1Click()
    $pw = _PWgen(GUICtrlRead($length),$letters)
    GUICtrlSetData($genpw,$pw)
EndFunc
Func Button2Click()
    GUICtrlSetData($genpw,"")
    GUICtrlSetData($length,"8")
    $letters = ""
    GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
EndFunc
Func Button3Click()
    Form1Close()
EndFunc
Func Checkbox1Click()
    $letters = "num"
    GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
EndFunc
Func Checkbox2Click()
    $letters = "alpha"
    GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
EndFunc
Func Checkbox3Click()
    $letters = "alphabig"
    GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
EndFunc
Func Checkbox4Click()
    $letters = "allnum"
    GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
EndFunc
Func Checkbox5Click()
    $letters = "all"
    GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
EndFunc
Func Form1Close()
exit
EndFunc
Func Form1Maximize()
    GUISetState(@SW_MAXIMIZE)
EndFunc
Func Form1Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc
Func Form1Restore()
    GUISetState(@SW_SHOW)
EndFunc

Func _PWgen($I_Lenght,$I_letter)
    Local $pass
If $I_Lenght <= 7 Or $I_Lenght >= 16 Then
    Return "Sorry password must be between 8 and 15 Characters"
Else
If $I_letter = "num" Then
    If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then
For $i = 0 to $I_Lenght -1
    $pass &= Random(0,9,1)
Next
Return $pass
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
ElseIf $I_letter = "alpha" Then
    If GuiCtrlRead($Checkbox2) = $GUI_CHECKED Then
For $i = 0 to $I_Lenght -1
    $pass &= Chr(Random(97,122,1))
Next
Return $pass
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
ElseIf $I_letter = "alphabig" Then
    If GuiCtrlRead($Checkbox3) = $GUI_CHECKED Then
For $i = 0 to $I_Lenght -1
    $pass &= Chr(Random(65,90,1))
Next
Return $pass
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
ElseIf $I_letter = "allnum" Then
    If GuiCtrlRead($Checkbox4) = $GUI_CHECKED Then
For $i = 0 to $I_Lenght -5
    $pass &= Chr(Random(65,90,1))
    $pass &= Chr(Random(97,122,1))
Next
Return $pass
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
ElseIf $I_letter = "all" Then
    If GuiCtrlRead($Checkbox5) = $GUI_CHECKED Then
For $i = 0 to $I_Lenght -7
    $pass &= Chr(Random(65,90,1))
    $pass &= Chr(Random(97,122,1))
    $pass &= Chr(Random(33,47,1))
    $pass &= Random(0,9,1)
Next
Return $pass
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
Else
    Return "No Lettertable Selected please select a Preset"
EndIf
EndIf
EndFunc

Help me please

Share this post


Link to post
Share on other sites



Switch statements don't need to be checked against the GuiGetMsg().

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $exititem
            Exit
        Case $aboutitem
            About()
    EndSwitch
WEnd

If you wanted Case $nMsg = $aboutitem then you would need a Select statement.

Also, you have two forms with the same name.

Share this post


Link to post
Share on other sites

Switch statements don't need to be checked against the GuiGetMsg().

CODEWhile 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $exititem

Exit

Case $aboutitem

About()

EndSwitch

WEnd

If you wanted Case $nMsg = $aboutitem then you would need a Select statement.

Also, you have two forms with the same name.

O... Yeah i fixed this thank you. But the _PWgen() func is not working. Why is that?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

O... Yeah i fixed this thank you. But the _PWgen() func is not working. Why is that?

Because the coding is so messed up.

It will never happen. You aren't asking for the right control variable.

Func Button1Click()
    $pw = _PWgen(GUICtrlRead($lenght), $letters)
    GUICtrlSetData($genpw, $pw)
EndFunc  ;==>Button1Click
Edited by JamesBrooks

Share this post


Link to post
Share on other sites

you are using OnEvent functions in both enable and disabled mode.

Remove everything from your while/wend except sleep(10) and it'll run.

you then need to run OnEvents for the exit and about functions.

Share this post


Link to post
Share on other sites

Thanks guys the tool is working great. But how can i make it to save the passwords and errors in a log. I dooesn't works with

_FileWriteLog

Help

Share this post


Link to post
Share on other sites

FileWriteLine seems straightforward enough.

Share this post


Link to post
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
Sign in to follow this  
Followers 0