NassauSky Posted April 16, 2022 Share Posted April 16, 2022 (edited) I am so close to getting a password show/reveal button working but not quite there. This sample works on the second mouse down event. I can't figure out what's going on yet. #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") $hGUI = GUICreate("Test", 500, 200) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) $cCheck = GUICtrlCreateButton("Show Password", 10, 50, 150, 20) GUISetState() $sDefaultPassChar = GUICtrlSendMsg($cInput, $EM_GETPASSWORDCHAR, 0, 0);Retrieve the ASCII value of the default password char While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCheck While 1 ConsoleWrite("_IsPressed - Left Mouse was pressed." & @CRLF) GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) GUICtrlSetState($cInput, $GUI_FOCUS) While _IsPressed("01", $hDLL) ; Wait until mouse is released. Sleep(20) WEnd ConsoleWrite("_IsPressed - Left Mouse was released." & @CRLF) GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, 0, 0) GUICtrlSetState($cInput, $GUI_FOCUS) ExitLoop Sleep(20) WEnd EndSwitch WEnd DllClose($hDLL) Thanks for any help. Edited April 16, 2022 by NassauSky Link to comment Share on other sites More sharing options...
NassauSky Posted April 17, 2022 Author Share Posted April 17, 2022 (edited) OK for anyone else interested. Thanks from the pieced together code help from @Yashied & @Melba23 expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <EditConstants.au3> #include <Misc.au3> Global $Over = False, $OldOver = False Local $hDLL = DllOpen("user32.dll") $Form1 = GUICreate('Form1', 230, 297, 303, 543) $Button1 = GUICtrlCreateButton('Reveal Password', 80, 100, 75, 25) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) GUISetState(@SW_SHOW) $sDefaultPassChar = GUICtrlSendMsg($cInput, $EM_GETPASSWORDCHAR, 0, 0) $hWnd = ControlGetHandle(WinGetHandle('Form1'), '', '[CLASS:Button; INSTANCE:1]') While 1 $tPoint = _WinAPI_GetMousePos() If _IsPressed("01", $hDLL) Then If Not $Over And _WinAPI_WindowFromPoint($tPoint) = $hWnd Then ConsoleWrite('Over' & @CR) $Over = 1 GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, 0, 0) GUICtrlSetState($cInput, $GUI_FOCUS) ControlClick ( $Form1, "", $cInput, "left" ) EndIf Else If $Over Then ConsoleWrite('Lost' & @CR) $Over = 0 GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) GUICtrlSetState($cInput, $GUI_FOCUS) ControlClick ( $Form1, "", $cInput, "left" ) EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE DllClose($hDLL) Exit EndSwitch WEnd Edited April 17, 2022 by NassauSky Link to comment Share on other sites More sharing options...
NassauSky Posted June 4 Author Share Posted June 4 Update: I just wanted to clean up the code since I needed it again: expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <EditConstants.au3> #include <Misc.au3> Global $Over = False Local $hDLL = DllOpen("user32.dll") Local $hGUI = GUICreate('Form1', 230, 297, 303, 543) Local $idButton = GUICtrlCreateButton('Reveal Password', 80, 100, 100, 25) Local $idInput = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) GUISetState(@SW_SHOW) ; Prep The Password Control Local $sDefaultPassChar = GUICtrlSendMsg($idInput, $EM_GETPASSWORDCHAR, 0, 0) Local $hButton = ControlGetHandle($hGUI, '', $idButton) While 1 ; Keep Checking For idButton Down $tPoint = _WinAPI_GetMousePos() If _IsPressed("01", $hDLL) Then If Not $Over And _WinAPI_WindowFromPoint($tPoint) = $hButton Then ConsoleWrite('idButton Down' & @CR) $Over = 1 GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, 0, 0) GUICtrlSetState($idInput, $GUI_FOCUS) ControlClick ( $hGUI, "", $idInput, "left" ) EndIf Else If $Over Then ConsoleWrite('idButton Up' & @CR) $Over = 0 GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) GUICtrlSetState($idInput, $GUI_FOCUS) ControlClick ( $hGUI, "", $idInput, "left" ) EndIf EndIf ; Process the standard messages $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE DllClose($hDLL) Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
ioa747 Posted June 4 Share Posted June 4 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> Global $hGUI = GUICreate('Form1', 250, 100, 303, 543) Global $idInput = GUICtrlCreateInput("Password", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) Global $idButton = GUICtrlCreateButton("👁", 212, 9, 25, 21) GUICtrlSetFont(-1, 14, 400, 0) GUISetState(@SW_SHOW) ; Prep The Password Control Global $sDefaultPassChar = GUICtrlSendMsg($idInput, $EM_GETPASSWORDCHAR, 0, 0) While 1 ; Process the standard messages $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _Reveal() WEnd Func _Reveal() Local Static $bPress Local $a = GUIGetCursorInfo($hGUI) If $a[2] = 1 And $a[4] = $idButton Then If $bPress = True Then Return GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, 0, 0) _WinAPI_RedrawWindow(GUICtrlGetHandle($idInput)) $bPress = True Else If $bPress = True Then $bPress = False GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) _WinAPI_RedrawWindow(GUICtrlGetHandle($idInput)) GUICtrlSetState($idInput, $GUI_FOCUS) Send("{RIGHT}") Sleep(100) EndIf EndIf EndFunc ;==>_Reveal Look at: https://www.autoitscript.com/forum/topic/211400-autoit-password-style Edited June 4 by ioa747 corection NassauSky 1 I know that I know nothing Link to comment Share on other sites More sharing options...
NassauSky Posted June 9 Author Share Posted June 9 @ioa747 Showoff 🙂 Nice and thanks for the reference link Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now