Trong Posted August 14, 2023 Share Posted August 14, 2023 For each password containing brackets I need to add it manually, do you have a piece of code that quickly converts it to a variable to insert into the code? Please help Example password file: R7PIO'24NJ7'5OI2J6'O23L64P23"J624P46P;46Z7PIO2'4NJ75OI2J6O23Y64P23J6"24P"46P;46T7PIO24N'J75OI2J6'O23T64P"23"J624"P46P;46K After converting: $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K' Regards, Link to comment Share on other sites More sharing options...
Danp2 Posted August 14, 2023 Share Posted August 14, 2023 I'm having trouble understanding why you need this. If the password is stored in a file, why can't you simply read it from the file using FileRead, FileReadLine, etc and assign the result to a variable? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Trong Posted August 14, 2023 Author Share Posted August 14, 2023 (edited) No, the password is not stored in the file. The file here is for quick conversion only. Because you can't paste it directly into the script, you need to save it to a file to convert it into a variable for quick copying into the script. ; BEGIN - Write Test file Local $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K' Local $My_Password_File = @ScriptDir & '\My_Password.txt' FileWrite($My_Password_File, $My_Password) ; END - Write test file Local $My_Password = FileRead($My_Password_File) FileDelete($My_Password_File) ; Remove test file ConsoleWrite("- " & $My_Password & @CRLF) Local $Pass_Process = '' If StringInStr($My_Password, "'") And StringInStr($My_Password, '"') Then ConsoleWrite('>1 ' & $My_Password & @CRLF) $Pass_Process = '###' & $My_Password & '###' ;;????????????????????????; ElseIf StringInStr($My_Password, "'") And (Not StringInStr($My_Password, '"')) Then ConsoleWrite('>2 ' & $My_Password & @CRLF) $Pass_Process = '"' & $My_Password & '"' Else ConsoleWrite('>3 ' & $My_Password & @CRLF) $Pass_Process = "'" & $My_Password & "'" EndIf ConsoleWrite("-> $My_Password = " & $Pass_Process & @CRLF) Edited August 14, 2023 by Trong Regards, Link to comment Share on other sites More sharing options...
Danp2 Posted August 14, 2023 Share Posted August 14, 2023 Then from where is the password obtained? FYI, you can double up the quotation marks, ie -- $sPwd = "R7PIO'24NJ7'5OI2J6'O23L64P23""J624P46P;46Z7PIO2'4NJ75OI2J6O23Y64P23J6""24P""46P;46T7PIO24N'J75OI2J6'O23T64P""23""J624""P46P;46K" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sPwd = ' & $sPwd & @CRLF & '>Error code: ' & @error & @CRLF) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Trong Posted August 14, 2023 Author Share Posted August 14, 2023 I want to avoid using double brackets to avoid confusion. Regards, Link to comment Share on other sites More sharing options...
Trong Posted August 14, 2023 Author Share Posted August 14, 2023 3 minutes ago, Danp2 said: Then from where is the password obtained? The password is randomly generated but is used consistently across different versions of the script. Regards, Link to comment Share on other sites More sharing options...
Danp2 Posted August 14, 2023 Share Posted August 14, 2023 I don't think I can help you with this since I'm unable to understand your use case. Maybe someone else will be better at deciphering your requirements. Gianni and Trong 2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Musashi Posted August 14, 2023 Share Posted August 14, 2023 17 minutes ago, Danp2 said: Maybe someone else will be better at deciphering your requirements. I hope, I am Local $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K' Local $dPasswordBin, $sPasswordStr ConsoleWrite($My_Password & @CRLF) $dPasswordBin = StringToBinary($My_Password) ConsoleWrite($dPasswordBin & @CRLF) ConsoleWrite(BinaryToString($dPasswordBin) & @CRLF) Gianni and Trong 2 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Gianni Posted August 14, 2023 Share Posted August 14, 2023 (edited) I think OP wants to generate a command to assign a variable ($My_Password) the password string if so then the best way would be to use double quotes to escape the single quotes (method 1) but if OP doesn't like this way then he could replace the quotes with chr(34) (method 2) If I didn't understand anything then sorry ; BEGIN - Write Test file Local $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K' Local $My_Password_File = @ScriptDir & '\My_Password.txt' FileWrite($My_Password_File, $My_Password) ; END - Write test file $My_Password = FileRead($My_Password_File) FileDelete($My_Password_File) ; Remove test file ConsoleWrite("- " & $My_Password & @CRLF& @CRLf) ; (method 1) ConsoleWrite('-> $My_Password = "' & StringReplace($My_Password, '"', '""') & '"' & @CRLF) ; (method 2) ConsoleWrite('-> $My_Password = "' & StringReplace($My_Password, '"', '" & Chr(34) & "') & '"' & @CRLF) Edited August 14, 2023 by Gianni Trong and Musashi 1 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Trong Posted August 15, 2023 Author Share Posted August 15, 2023 I want to see the character up didn't want to use StringtoBinary for encoding. Using StringReplace would probably be the simplest solution. Regards, 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