Jump to content

Text recovery in a window ?


Go to solution Solved by ioa747,

Recommended Posts

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 by teodoric666
Link to comment
Share on other sites

  • Solution
Posted (edited)

put on the top of your script

Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled

 

#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 by ioa747

I know that I know nothing

Link to comment
Share on other sites

  • Moderators

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.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • teodoric666 changed the title to Text recovery in a window ?

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