teodoric666 Posted March 26 Share Posted March 26 (edited) hello still in my research I have problems displaying passwords in the window and then copying, thank you , my test code just for the fun #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI, $hOutput, $hCopyButton $hGUI = GUICreate("test pass", 400, 300) GUICtrlCreateButton("pass", 50, 50, 300, 30) GUICtrlSetOnEvent(-1, "GeneratePassword") $hOutput = GUICtrlCreateEdit("", 50, 100, 300, 150) ;GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_SHOW) $hCopyButton = GUICtrlCreateButton("Copy", 50, 260, 100, 30) GUICtrlSetOnEvent(-1, "CopyPassword") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func GeneratePassword() Local $length = Random(8, 16, 1) ; Longueur du mot de passe (entre 8 et 16 caractères) Local $password = GenerateRandomPassword($length) GUICtrlSetData($hOutput, $password) EndFunc Func GenerateRandomPassword($length) Local $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+{}[]|\/?<>,." Local $password = "" For $i = 1 To $length $password &= StringMid($characters, Random(1, StringLen($characters), 1), 1) Next Return $password EndFunc Func CopyPassword() Local $password = GUICtrlRead($hOutput) ClipPut($password) MsgBox(0, "Copy", "the password has been copied to the clipboard.") EndFunc Edited March 27 by teodoric666 Link to comment Share on other sites More sharing options...
Solution ioa747 Posted March 26 Solution Share Posted March 26 (edited) put on the top of your script Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled Global $hGUI, $hOutput, $hCopyButton $hGUI = GUICreate("test pass", 400, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICtrlCreateButton("pass", 50, 50, 300, 30) GUICtrlSetOnEvent(-1, "GeneratePassword") $hOutput = GUICtrlCreateEdit("", 50, 100, 300, 150) ;GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_SHOW) $hCopyButton = GUICtrlCreateButton("Copy", 50, 260, 100, 30) GUICtrlSetOnEvent(-1, "CopyPassword") GUISetState(@SW_SHOW, $hGUI) While 1 Sleep(50) WEnd Func GeneratePassword() Local $length = Random(8, 16, 1) ; Longueur du mot de passe (entre 8 et 16 caractères) Local $password = GenerateRandomPassword($length) GUICtrlSetData($hOutput, $password) EndFunc ;==>GeneratePassword Func GenerateRandomPassword($length) Local $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+{}[]|\/?<>,." Local $password = "" For $i = 1 To $length $password &= StringMid($characters, Random(1, StringLen($characters), 1), 1) Next Return $password EndFunc ;==>GenerateRandomPassword Func CopyPassword() Local $password = GUICtrlRead($hOutput) ClipPut($password) MsgBox(0, "Copy", "the password has been copied to the clipboard.") EndFunc ;==>CopyPassword Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ConsoleWrite("Close Pressed, ID=" & @GUI_CtrlId & ", WinHandle=" & @GUI_WinHandle & @CRLF) GUIDelete() Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ConsoleWrite("Window Minimized, ID=" & @GUI_CtrlId & ", WinHandle=" & @GUI_WinHandle & @CRLF) Case @GUI_CtrlId = $GUI_EVENT_RESTORE ConsoleWrite("Window Restored, ID=" & @GUI_CtrlId & ", WinHandle=" & @GUI_WinHandle & @CRLF) EndSelect EndFunc ;==>SpecialEvents see this too https://www.autoitscript.com/forum/topic/209799-regex-validates-as-true-when-it-should-not/ Edited March 26 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
teodoric666 Posted March 26 Author Share Posted March 26 ah !!!! yes !!!!! thank's Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26 Moderators Share Posted March 26 teodoric666, Quote displaying passwords in the window and then copying And just why do you need to show and then copy passwords? M23 P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
teodoric666 Posted March 26 Author Share Posted March 26 it's just tests that I'm doing because I've been starting autoit for a month and I'm having a lot of trouble with inputs and outputs and how to recover the data, there is no desire to hack and if my post bothers I understand and remove it immediately I put a password as I would have put any data a text for example. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26 Moderators Share Posted March 26 teodoric666, I have now read your script more carefully and I am happy there is no problem, other than you unfortunate choice of word in the thread title! M23 teodoric666 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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