Jump to content

InputBox as password


Recommended Posts

Using it like this currently:

$Password = InputBox ( "Login", "Please input the password" , "" , "*M" , "" , "" , "" , "" , "30" )

If $Password = "Test" Then

MsgBox ("0", "", "Correct")

Else

MsgBox ("0", "Failed", "Incorrect Password")

EndIf

2 questions. How can i make it case sensitive? it currently is not.

any way to keep the box at the center of the screen and stil have a 30 second timeout without getting pixels? Sorry if this is a nooby question. Been scripting for a while with autoIT now, but the whole GUI portion is starting to get tricky

If im missing a different command please feel free to express your vet-rage at my noobness

Link to comment
Share on other sites

  • Moderators

RedneckTech,

If $Password == "Test" Then

will make the comparison case sensitive. :)

any way to keep the box at the center of the screen and stil have a 30 second timeout without getting pixels?

Would you care to explain in more detail as I do not understand - this works fine for me: :huh:

InputBox ( "title", "prompt", "", "", Default, Default, Default, Default, 30)

If you want the GUI to be undraggable then you need to create your own version of it using GUICreate - InputBox is produced by the API and you cannot really interact with it. ;)

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

For a case sensitive compare replace

If $Password = "Test" Then
with
If $Password == "Test" Then
or
if StringCompare($Password, "Test", 1) = 0 Then
Edit: Too sloooooooowwwww!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I tried, but the password is not case sensitive. and i did not know about the "Default" parameter. Thanks M23, and to you too water. i like the stringcompare function. i will have to use that actually

any way to keep the box at the center of the screen and stil have a 30 second timeout without getting pixels? = i wanted a 30 sec timeout, but wanted the box to stay centered. was not using the "Default" parameter

Edit: missed the 2nd = in your statement M23

Edited by RedneckTech
Link to comment
Share on other sites

  • Moderators

RedneckTech,

So are you happy with the code now? :huh:

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

Heres what I ended up writing. Sensitive information replaced with *** of course:

#include <Timers.au3>

If FileExists ( @WorkingDir & "Diconnect.bat" ) = 0 Then
   FileOpen ( @WorkingDir & "Disconnect.bat", 1)
   FileWriteLine ( @WorkingDir & "Disconnect.bat" , "taskkill /im openvpn.exe /f" )
   FileWriteLine ( @WorkingDir & "Disconnect.bat" , "taskkill /im openvpn-gui.exe /f")
   FileClose ( @WorkingDir & "Disconnect.bat" )
   Sleep (100)
EndIf

$Password = InputBox ( "Login to ****", "Please input the password to connect to *********** , "" , "*M" , Default , Default , Default , Default , "30" )
If $Password == "*****" Then
   Run ( @WorkingDir & "Disconnect.bat" )
   Sleep ( 2000 )
   $Startup = TimerInit()
   While ProcessExists ( "openvpn-gui.exe") <> 0
      If TimerDiff($Startup) > 10000 Then
         MsgBox ( "0", "Error" , "ERROR" & @CRLF & "If this is the first time you have seen this error, please try rerunning the program again" & @CRLF & "If not please Contact email@email.com" )
         Exit
      EndIf
      Sleep (20)
   WEnd
   Run (@comspec & " /c " & Chr(34) & "C:Program FilesOpenVPNbinopenvpn-gui.exe" & Chr(34) & " --connect *****************.ovpn")
Else
   MsgBox ("0", "Failed", "Password Invalid")
   Run ( @WorkingDir & "Disconnect.bat" )
EndIf

$openvpn = TimerInit()

While ProcessExists ("openvpn.exe") <> 0
   If TimerDiff($openvpn) > 14400000 Then
      Run ( @WorkingDir & "Disconnect.bat" )
   EndIf
   If _Timer_GetIdleTime() >= 1200000 Then
      Run ( @WorkingDir & "Disconnect.bat" )
   EndIf
   Sleep (10000)
WEnd

We have a user that is computer retarded and needs a vpn connection to our server. rather than have just the standard openvpn gui which is open to her kids we figured this was better. Thanks guys!

Edit: added M23's code tags as per request

Edited by RedneckTech
Link to comment
Share on other sites

how are you choosing to store the password? hard coded, in a file, or off the network?

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

  • Moderators

RedNeckTech,

Glad we could help. :)

And when you post code, please use Code tags - put [autoit] before and [/autoit] after your posted code - then you get the nice scrolling box and syntax colouring. ;)

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

its specifically written for her and no ones getting on her computer so it is just hardcoded at this point. it is not her network password, just something to keep anyone from fuddling around

I see. If you ever wanted to make it a bit more secure, you can encrypt the password, and store it encrypted (even hard coded) so no one can read it without decrypting it first.You can use this to encrypt any password. It also outputs the command you should paste into the script for a simple login prompt.

Had to dig around for this...

#include <Crypt.au3>

$vData = InputBox(@ScriptName, "Enter a password to encrypt.")
$sOutFile = FileSelectFolder("Select folder to output your encrypted key to.", "", 6)
If @error Then Exit
$sOutFile&="\EncryptedPass.txt"
_AutoMD5_Data_Create($vData, $sOutFile)
If msgbox(4 + 32 + 262144, @ScriptName, "Do you wish to view your encrypted key?") = 6 Then ShellExecute($sOutFile)
Exit

Func _AutoMD5_Data_Create($vData, $sOutFile)
    _Crypt_StartUp()
    $sEncryptedString = _Crypt_HashData($vData, $CALG_MD5)
    If $sEncryptedString = -1 Then
        msgbox(16 + 262144, @ScriptName, "Failed to create MD5 hash. Error in command. " & @error)
        Exit
    Else
        $hFile = FileOpen($sOutFile, 2)
        FileWrite($hFile, String($sEncryptedString) & @CRLF)
        FileClose($hFile)
    EndIf
    _Crypt_Shutdown()
    If msgbox(4 + 32 + 262144, @ScriptName, "Do you wish to test the output?") = 6 Then
        $sInput = InputBox(@ScriptName, "Enter your password...")
        _AutoMD5_Test_Decryption($sInput, $sEncryptedString, $sOutFile)
    EndIf
    _AutoMD5_Create_Commands($sOutFile)
    Return $sEncryptedString
EndFunc

Func _AutoMD5_Test_Decryption($sInput, $sEncryptedString, $sOutFile)
    _Crypt_Startup()
    $sInputEncryptedString = _Crypt_HashData($sInput, $CALG_MD5)
    _Crypt_Shutdown()
    If String($sInputEncryptedString) = String($sEncryptedString) Then
        msgbox(64 + 262144, @ScriptName, "WORKS!" &@LF&@LF& _
            "Encrypted Password Shows As: " & @TAB & $sEncryptedString &@LF&@LF& _
            "The Input Password Shows As: " & @TAB & $sInputEncryptedString)
    Else
        msgbox(64 + 262144, @ScriptName, "FAILED!" &@LF&@LF& _
        "Encrypted Password Shows As: " & @TAB & $sEncryptedString &@LF&@LF& _
            "The Input Password Shows As: " & @TAB & $sInputEncryptedString)
    EndIf
EndFunc

Func _AutoMD5_Create_Commands($sOutFile)
    $hFile = FileOpen($sOutFile, 1)
    FileWrite($hFile,  @CRLF & '#include <Crypt.au3>' & @CRLF & @CRLF & _
        '$sInput = InputBox(@ScriptName, "Enter your password...")' & @CRLF & @CRLF & _
        'Func _AutoMD5_Data_Decrypt($sInput) ; Returns true if passwords match, or false if they don''t.' & @CRLF & @TAB & _
        '$sPass = _Get_Stored_Encrypted_Password() ; Retrieve the password via whatever method you choose to store it.' & @CRLF & @TAB & _
        '_Crypt_Startup()' & @CRLF & @TAB & _
        '$sEncryptedInput = _Crypt_HashData($sInput, $CALG_MD5)' & @CRLF & @TAB & _
        '_Crypt_Shutdown()' & @CRLF & @TAB & _
        'If String($sInputEncryptedString) = String($sEncryptedString) Then' & @CRLF & @TAB & @TAB & _
        'Return True' & @CRLF & @TAB & _
        'Else' & @CRLF & @TAB & @TAB & _
        'Return False' & @CRLF & @TAB & _
        'EndIf' & @CRLF & _
        'EndFunc')
    FileClose($hFile)
EndFunc

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

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