Jump to content

Edit style problem (can't get $ES_PASSWORD to work)


Spaldy
 Share

Recommended Posts

Hey I can't seem to get my edit box to use the $ES_PASSWORD style however the additional style ($ES_CENTER) does work and i can't figure out how to get the password style to work but i got it right because the center works so i'm confused and need some help

Opt("GUIOnEventMode", 1); Change to OnEvent mode
$mainwindow = GUICreate("Password Please", 200, 150)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$okbutton = GUICtrlCreateButton("Check Password", 50, 100, 100, 30)
GUICtrlSetOnEvent($okbutton, "Checkpassword")
$Edit = GUICtrlCreateEdit(""& @CRLF, 25, 20, 150, 60,$ES_PASSWORD+$ES_CENTER) 
GUISetState(@SW_SHOW)

While 1
    Sleep(2000); Idle around
WEnd

Func Checkpassword()
    GUICtrlRead($Edit)
    $Password = "password";Note: could make password anything here
    If GUICtrlRead($Edit) = $Password Then;password is correct
;Note: at this point @GUI_CtrlId would equal $okbutton,
;And @GUI_WinHandle would equal $mainwindow
;Note: option to put other func here
        Exit
        
    Else;Pasword is incorrect
;Note: option to put other func here
            MsgBox(48,"Oops!", "Wrong Password! Try Again...", 2)
    EndIf
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
;and @GUI_WINHANDLE would equal $mainwindow 
  Exit
  EndFunc

Sorry if it's a bit messy but i only started using Autoit a month ago

Edited by Spaldy

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

Link to comment
Share on other sites

Hey I can't seem to get my edit box to use the $ES_PASSWORD style however the additional style ($ES_CENTER) does work and i can't figure out how to get the password style to work but i got it right because the center works so i'm confused and need some help

Opt("GUIOnEventMode", 1); Change to OnEvent mode
$mainwindow = GUICreate("Password Please", 200, 150)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$okbutton = GUICtrlCreateButton("Check Password", 50, 100, 100, 30)
GUICtrlSetOnEvent($okbutton, "Checkpassword")
$Edit = GUICtrlCreateEdit(""& @CRLF, 25, 20, 150, 60,$ES_PASSWORD+$ES_CENTER) 
GUISetState(@SW_SHOW)

While 1
    Sleep(2000); Idle around
WEnd

Func Checkpassword()
    GUICtrlRead($Edit)
    $Password = "password";Note: could make password anything here
    If GUICtrlRead($Edit) = $Password Then;password is correct
;Note: at this point @GUI_CtrlId would equal $okbutton,
;And @GUI_WinHandle would equal $mainwindow
;Note: option to put other func here
        Exit
        
    Else;Pasword is incorrect
;Note: option to put other func here
            MsgBox(48,"Oops!", "Wrong Password! Try Again...", 2)
    EndIf
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
;and @GUI_WINHANDLE would equal $mainwindow 
  Exit
  EndFunc

Sorry if it's a bit messy but i only started using Autoit a month ago

#include <EditConstants.au3>

or

$ES_PASSWORD = 0x0020

When the words fail... music speaks.

Link to comment
Share on other sites

I changed some things

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

$mainwindow = GUICreate("Password Please", 200, 110)
$okbutton = GUICtrlCreateButton("Check Password", 50, 70, 100, 30)
$INPUT = GUICtrlCreateInput("", 25, 20, 150, 20,BitOR($ES_PASSWORD,$ES_CENTER))
GUISetState(@SW_SHOW)

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $okbutton
            Checkpassword()
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func Checkpassword()
    GUICtrlRead($INPUT)
    $Password = "password";Note: could make password anything here
    If GUICtrlRead($INPUT) = $Password Then;password is correct
        MsgBox(0,"Check Password","Correct password")
;Note: at this point @GUI_CtrlId would equal $okbutton,
;And @GUI_WinHandle would equal $mainwindow
;Note: option to put other func here
        Exit
        
    Else;Pasword is incorrect
;Note: option to put other func here
            MsgBox(48,"Oops!", "Wrong Password! Try Again...", 2)
    EndIf
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

Hey thanks but that still doesn't get the Edit to replace characters to an asterix (*) it just changes the edit to a Input but it works and you can't argue with results!

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

Link to comment
Share on other sites

Hey thanks but that still doesn't get the Edit to replace characters to an asterix (*) it just changes the edit to a Input but it works and you can't argue with results!

I run the script from post#3

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Link to comment
Share on other sites

Spaldy

Use GuiEdit.au3 UDF

#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode

$mainwindow = GUICreate("Password Please", 200, 150)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$okbutton = GUICtrlCreateButton("Check Password", 50, 100, 100, 30)
GUICtrlSetOnEvent($okbutton, "Checkpassword")

$hEdit = _GUICtrlEdit_Create($mainwindow, "", 25, 20, 150, 60, BitOR($ES_PASSWORD, $ES_CENTER))

GUISetState(@SW_SHOW)

While 1
    Sleep(2000); Idle around
WEnd

Func Checkpassword()
    $EditText = _GUICtrlEdit_GetText($hEdit)
    ConsoleWrite("!> Edit text: " & $EditText & @LF)
    $Password = "password";Note: could make password anything here
    If $EditText = $Password Then;password is correct
;Note: at this point @GUI_CtrlId would equal $okbutton,
;And @GUI_WinHandle would equal $mainwindow
;Note: option to put other func here
        Exit
        
    Else;Pasword is incorrect
;Note: option to put other func here
            MsgBox(48,"Oops!", "Wrong Password! Try Again...", 2)
    EndIf
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
;and @GUI_WINHANDLE would equal $mainwindow 
  Exit
  EndFunc
Link to comment
Share on other sites

Thanks for all the help :P

I can't see a reason why you need a password protected edit box.....

this is just a small addition to a larger project of mine and i needed to add security to it

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

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...