Sign in to follow this  
Followers 0
Rawox

Password Field Show/Hide Option

5 posts in this topic

#1 ·  Posted (edited)

Hi!

I'm making an Gmail Auto Login Script. Just for myself :)

In the GUI, I want to have an option that shows or hides the password in the password field

So you can see **** or just letters.

I already designer the GUI, does anyone knows how to make it work?

EDIT: I modified something, I changed the checkbox into a button that already changes to the other thing but doesn't changes back :lmao:

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

Opt("WinTitleMatchMode", 2); Other Option for WinWaitActive

Local $msg

;=============BASE==============
$GUI = GUICreate("Title", 200, 170, -1, -1)
GuiSetFont ( 8.5, 600 )
GUICtrlCreateGroup ( "Username", 10, 8, 180, 45 )
GuiSetFont ( 8.5, 400 )
$Username = GUICtrlCreateInput( "", 20, 25, 160, 20 )
GuiSetFont ( 8.5, 600 )
GUICtrlCreateGroup ( "Password", 10, 58, 180, 70 )
GuiSetFont ( 8.5, 400 )
$Password = GUICtrlCreateInput( "", 20, 75, 160, 20, $ES_PASSWORD )
$Go = GUICtrlCreateButton( "Go!", 10, 137, 180, 25 )
;=============CHECKBOX==============
$button = GUICtrlCreateButton ( "Show Password", 20, 97, 160, 23 )


GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3
        FileDelete(@ScriptDir & "\pic00.jpeg")
        Exit
    Case $nMsg = $Go
        _gMail_Create()
    Case $nMsg = $button
        GUICtrlSetData($button, "Hide Password")
    EndSelect
WEnd



;GMAIL FUNCTION
Func _gMail_Create()
    $gMail = Run ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
    WinWaitActive ( "Mozilla Firefox" )
    WinSetState ( "Mozilla Firefox", "", @SW_MAXIMIZE )
    Send ( "{F6}" )
    Send ( "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginAuth%3Fservice%3Dmail&il=true&zx=1tyc3ues9dy7y {ENTER}" )
    WinWaitActive ( "Gmail" )
    Sleep ( 2000 )
    
    Global $iColor = 0xE8EEFA
    $coord = PixelSearch( 952, 256, 1220, 530, $iColor, 10 )
    Sleep ( 500 )
    MouseClick ( "left", $coord[0], $coord[1], 1, 1 )
    Sleep ( 500 )
    
    Send ( "{TAB}" )
    Sleep ( 2000 )
    Send ( GUICtrlRead($Username) )
    Send ( "{TAB}" )
    Send ( GUICtrlRead($Password) )
;Send ( "{ENTER}" )

    GUISetState()
    While 1
        $_nMsg = GUIGetMsg()
            Select
        Case $_nMsg = -3
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        EndSelect
    WEnd
EndFunc

.Rawox

Edited by Rawox

Share this post


Link to post
Share on other sites



Best I could come up with was this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
$shown = True

$Form1 = GUICreate("Form1", 140, 74, 193, 125)
$Input1 = GUICtrlCreateInput("Input1", 8, 8, 121, 21)
$Button1 = GUICtrlCreateButton("Show/Hide", 8, 40, 123, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $read = GUICtrlRead ($Input1)
            GUICtrlDelete ($Input1)
            If $shown Then
                $shown = False
                $Input1 = GUICtrlCreateInput($read, 8, 8, 121, 21, $ES_PASSWORD)
            Else
                $shown = True
                $Input1 = GUICtrlCreateInput($read, 8, 8, 121, 21, $GUI_SS_DEFAULT_INPUT)
            EndIf
    EndSwitch
WEnd

It seems that this doesn't work:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
$shown = True

$Form1 = GUICreate("Form1", 140, 74, 193, 125)
$Input1 = GUICtrlCreateInput("Input1", 8, 8, 121, 21)
$Button1 = GUICtrlCreateButton("Show/Hide", 8, 40, 123, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If $shown Then
                $shown = False
                GUICtrlSetStyle ($Input1, $ES_PASSWORD)
            Else
                $shown = True
                GUICtrlSetStyle ($Input1, $GUI_SS_DEFAULT_INPUT)
            EndIf
    EndSwitch
WEnd

I believe it is because the style cannot be dynamically changed to have $ES_PASSWORD. Either that or my code is wrong.... :)

Cheers,

Brett

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Not totally working, when I click show Password then I need to click twice...

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

Opt("WinTitleMatchMode", 2); Other Option for WinWaitActive

Local $msg
$shown = True

;=============BASE==============
$GUI = GUICreate("Title", 200, 170, -1, -1)
GuiSetFont ( 8.5, 600 )
GUICtrlCreateGroup ( "Username", 10, 8, 180, 45 )
GuiSetFont ( 8.5, 400 )
$Username = GUICtrlCreateInput( "", 20, 25, 160, 20 )
GuiSetFont ( 8.5, 600 )
GUICtrlCreateGroup ( "Password", 10, 58, 180, 70 )
GuiSetFont ( 8.5, 400 )
$Password = GUICtrlCreateInput( "", 20, 75, 160, 20, $ES_PASSWORD )
$Go = GUICtrlCreateButton( "Go!", 10, 137, 180, 25 )
;=============CHECKBOX==============
$button = GUICtrlCreateButton ( "Show Password", 20, 97, 160, 23 )
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    
    Select
    Case $nMsg = -3
        FileDelete(@ScriptDir & "\pic00.jpeg")
        Exit
        
    Case $nMsg = $Go
        _gMail_Create()
        
    Case $nMsg = $button
         $read = GUICtrlRead ($Password)
            GUICtrlDelete ($Password)
                If $shown Then
                    $shown = False
                    $Password = GUICtrlCreateInput($read, 20, 75, 160, 20, $ES_PASSWORD)
                    GUICtrlSetData($button, "Show Password")
                Else
                    $shown = True
                    $Password = GUICtrlCreateInput($read, 20, 75, 160, 20, $GUI_SS_DEFAULT_INPUT)
                    GUICtrlSetData($button, "Hide Password")
                EndIf
    EndSelect
WEnd



;GMAIL FUNCTION
Func _gMail_Create()
    $gMail = Run ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
    WinWaitActive ( "Mozilla Firefox" )
    WinSetState ( "Mozilla Firefox", "", @SW_MAXIMIZE )
    Send ( "{F6}" )
    Send ( "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginAuth%3Fservice%3Dmail&il=true&zx=1tyc3ues9dy7y {ENTER}" )
    WinWaitActive ( "Gmail" )
    Sleep ( 2000 )
    
    Global $iColor = 0xE8EEFA
    $coord = PixelSearch( 952, 256, 1220, 530, $iColor, 10 )
    Sleep ( 500 )
    MouseClick ( "left", $coord[0], $coord[1], 1, 1 )
    Sleep ( 500 )
    
    Send ( "{TAB}" )
    Sleep ( 2000 )
    Send ( GUICtrlRead($Username) )
    Send ( "{TAB}" )
    Send ( GUICtrlRead($Password) )
;Send ( "{ENTER}" )

    GUISetState()
    While 1
        $_nMsg = GUIGetMsg()
            Select
        Case $_nMsg = -3
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        EndSelect
    WEnd
EndFunc

Any Ideas?

Edited by Rawox

Share this post


Link to post
Share on other sites

Ok, I fixed it: I changed

$shown = True

To...

$shown = False

Don't know why,, but it worked :)

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