gseller Posted December 1, 2008 Share Posted December 1, 2008 Hello, I am writing a script to read a decrypted user/pass from an ini and change to keycode. I have a function made to read and decrypt the password and StringRegExpReplace but cannot see how to convert the read string to keycode? Can someone help me out? expandcollapse popup$hWnd = WinGetHandle(WinGetTitle("")) ;Speacial thanks to DBaK for his #include-once ;I use this line just so that I don't include files twice by acident and cause an error #include <String.au3> ;We need this file for the Encrypt/Decrypt #include <GUIConstants.au3> ;We need this file to create a GUI Global $INI = @ScriptDir & "\pswd.ini" ;Here we define what file our password is In Global $Section = 'login' ;Here we define what section we will use in our ini Global $Key = 'XXXX' ;Here we define which key we will want to use Global $EncryptKey = 'abcd' ;This is the encryption key Global $EncryptLevel = '2' ;This is our level of encryption #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Login Config", 176, 80, 193, 115) Global $Button1 = GUICtrlCreateButton("Create Login", 8, 0, 75, 25, 0) Global $Button2 = GUICtrlCreateButton("Verify Login", 88, 0, 75, 25, 0) Global $Button3 = GUICtrlCreateButton("See My Login", 44, 45, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 _Store() Case $button2 _Login() Case $button3 _ReadLogin() EndSwitch WEnd Func _Store() ;This function will write our encrypted password $PSWD = _InputBox("Create or Manage Login", "Type login... " & @LF & "[Only Numbers are allowed]" & @LF & "[Maximum 8 Numbers]", _ "", 1, 1, 8, -1, 220, -1, -1, 0, 0x00000008, 10, $hWnd) ;$PSWD = InputBox( 'Store Password', 'New Password', '', '|' ) ;Help file will explain this ;I don't check to see if you pressed cancel but you can handel that $PSWD = _StringEncrypt ( 1, $PSWD, $EncryptKey , $EncryptLevel ) IniWrite( $INI, $SECTION, $KEY, $PSWD ) ;You can also use literal strings but to make this ;more dynamic I used varialbles EndFunc Func _Login() $Actual_Password = IniRead( $INI, $SECTION, $KEY, '' ) ;This will read the INI for a password If $Actual_Password = '' Then MsgBox(64, 'Error', 'No Login Created' ) Return Endif $Actual_Password = _StringEncrypt ( 0, $Actual_Password, $EncryptKey , $EncryptLevel ) ;This will decrypt the text into the ;string you used to store it as. For $i = 1 to 3 step 1 ;this means that $i = 1 and it will exit the loop when $i = 3 and each time ;it loops through it will step/add +1 to $i $Temp = InputBox( 'Your Login', 'Login Digits', '', '|' );Help file will explain this GUICtrlSetLimit(-1,6) ; to limit the entry to 6 chars IF $temp = '' then Return ;If you dont type anything then just go back to the main loop If $temp <> $Actual_Password Then MsgBox(32, 'Error', 'Wrong login entered!' ) Else MsgBox(32,'YES!', 'Correct login entered!') Return ;Sends you back to the main loop Endif Next ;This loop makes it so that the user only has 3 tries to log in but ;if you take our the 'Next' line and the 'For $i = 1 to 3 step 1' line then they will only have one chance EndFunc Func _InputBox($Title,$Promt,$Default="",$IsPassword=0,$IsDigits=0,$Limit=-1,$Width=-1,$Height=-1,$Left=-1,$Top=-1,$Style=0,$exStyle=0,$Timeout=0,$hWnd=0) Local $OldOpt = Opt("GuiOnEventMode", 0) WinSetState($hWnd, "", @SW_DISABLE) If $Width < 200 Then $Width = 200 If $Height < 150 Then $Height = 150 Local $InputGui, $OKButton, $CancelButton, $InputBoxID, $Msg, $GuiCoords, $RetValue, $InputMsg, $TimerStart $InputGui = GUICreate($Title, $Width, $Height, $Left, $Top, 0x00040000+$Style, $exStyle, $hWnd) GUICtrlCreateLabel($Promt, 15, 5, $Width, $Height-105) GUICtrlSetResizing(-1, 256+512) $OKButton = GUICtrlCreateButton("OK", ($Width/2)-70, $Height-95, 60, 25) GUICtrlSetResizing(-1, 0x0240) $CancelButton = GUICtrlCreateButton("Cancel", ($Width/2)+10, $Height-95, 60, 25) GUICtrlSetResizing(-1, 0x0240) If $IsPassword <> 0 Then $IsPassword = 32 If $IsDigits <> 0 Then $IsDigits = 8192 $InputBoxID = GUICtrlCreateInput($Default, 20, $Height-60, $Width-40, 20, $IsPassword+$IsDigits+128, 0x00000001) GUICtrlSetResizing(-1, 0x0240) GUICtrlSetState(-1, 256) If $Limit <> -1 Then GUICtrlSetLimit(-1, $Limit) GUISetState(@SW_SHOW, $InputGui) If $Timeout > 0 Then $TimerStart = TimerInit() While 1 $InputMsg = GUIGetMsg() Switch $InputMsg Case -3, $CancelButton WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($InputGui) Opt("GuiOnEventMode", $OldOpt) Return SetError(1, 0, "") Case $OKButton $RetValue = GUICtrlRead($InputBoxID) WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($InputGui) Opt("GuiOnEventMode", $OldOpt) Return SetError(0, 0, $RetValue) EndSwitch If $Timeout > 0 And Round(TimerDiff($TimerStart)/1000) = $Timeout Then $RetValue = GUICtrlRead($InputBoxID) WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($InputGui) Opt("GuiOnEventMode", $OldOpt) Return SetError(2, 0, $RetValue) EndIf WEnd EndFunc Func _ReadLogin() $Actual_Password = IniRead( $INI, $SECTION, $KEY, '' ) ;This will read the INI for a password If $Actual_Password = '' Then MsgBox(64, 'Error', 'No Password Stored' ) Return Endif $Actual_Password = _StringEncrypt ( 0, $Actual_Password, $EncryptKey , $EncryptLevel ) ;This will decrypt the text into the MsgBox(0, "login Info entered", StringRegExpReplace("You entered: " & $Actual_Password, "[0-9]", "X")) EndFunc Link to comment Share on other sites More sharing options...
martin Posted December 1, 2008 Share Posted December 1, 2008 I hope I'm not missing something here, but if you replace MsgBox(0, "login Info entered", StringRegExpReplace("You entered: " & $Actual_Password, "[0-9]", "X")) with MsgBox(0, "login Info entered", $Actual_Password) does it show what you want? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
gseller Posted December 1, 2008 Author Share Posted December 1, 2008 I hope I'm not missing something here, but if you replace MsgBox(0, "login Info entered", StringRegExpReplace("You entered: " & $Actual_Password, "[0-9]", "X")) with MsgBox(0, "login Info entered", $Actual_Password) does it show what you want? Well, you are right but what I am needing to do is this: Say the password is 12345678 What I need for a send command is {NUMPAD1}{NUMPAD2}{NUMPAD3}{NUMPAD4}{NUMPAD5}{NUMPAD6}{NUMPAD7}{NUMPAD8} Any ideas? Link to comment Share on other sites More sharing options...
martin Posted December 1, 2008 Share Posted December 1, 2008 (edited) Well, you are right but what I am needing to do is this: Say the password is 12345678 What I need for a send command is {NUMPAD1}{NUMPAD2}{NUMPAD3}{NUMPAD4}{NUMPAD5}{NUMPAD6}{NUMPAD7}{NUMPAD8} Any ideas?What is wrong with sending "12345678"? If you have to use the number pad keys then could you do something like $apw = stringsplit($password,"") for $n = 1 to $apw[0] Send({NUMPAD" & $apw[$n] & "}") next EDIT - added missing quotation mark. Edited December 1, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
torels Posted December 1, 2008 Share Posted December 1, 2008 You could use StringRegExpReplace[0-9] --> {numpadX} and so on for Uppercase and Lowercase letters Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
martin Posted December 1, 2008 Share Posted December 1, 2008 You could use StringRegExpReplace[0-9] --> {numpadX} and so on for Uppercase and Lowercase lettersYes torels, that's better than what I suggested $password = "123456" $sendString = StringRegExpReplace($password,"[0-9]","{NUMPAD\0}") consolewrite($sendString & @CR) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
gseller Posted December 1, 2008 Author Share Posted December 1, 2008 In this case I am having to use Send() and and this is loging into a VB scripted application and unfortunately will only accept keycode like {NUMPAD0} for numeric keys. It will however use regular alpha keys. Link to comment Share on other sites More sharing options...
gseller Posted December 1, 2008 Author Share Posted December 1, 2008 You could use StringRegExpReplace[0-9] --> {numpadX} and so on for Uppercase and Lowercase letters cool, that does play out well in console.. Thanks Both.. This gives me something to build on.. And Thank you martin.. A Great Help! 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