Jump to content

FrancescoDiMuro

Active Members
  • Posts

    2,658
  • Joined

  • Last visited

  • Days Won

    19

Everything posted by FrancescoDiMuro

  1. @dphuc23 With a different approach, this would be helpful: #include <Array.au3> #include <StringConstants.au3> #include <MsgBoxConstants.au3> MsgBox($MB_ICONINFORMATION, "GetDateTimeFromWorldTimeAPI", GetDateTimeFromWorldTimeAPI("http://worldtimeapi.org/api/timezone/Asia/Bangkok")) _ArrayDisplay(GetDateTimeArrayFromWorldTimeAPI("http://worldtimeapi.org/api/timezone/Asia/Bangkok"), "GetDateTimeArrayFromWorldTimeAPI") Func GetDateTimeFromWorldTimeAPI($strAddress) Return StringRegExp(BinaryToString(INetRead($strAddress,1)), '"datetime":"([^"]+)"', $STR_REGEXPARRAYMATCH)[0] EndFunc Func GetDateTimeArrayFromWorldTimeAPI($strAddress) Return StringRegExp(BinaryToString(INetRead($strAddress,1)), '"datetime":"(\d{4}\-\d{2}\-\d{2})T(\d{2}:\d{2}:\d{2}\.\d+)([+-]\d+:\d+)"', $STR_REGEXPARRAYMATCH) EndFunc Cheers
  2. @Yodavish If you are still interested in automating this application without Send() function, you should download UIASpy and try to use UIAutomation. In that case, you'll probably have more information and more ways to automate your application
  3. @Yodavish Check the usage of ControlGetHandle with ID parameter; there's a space after ID, and you could just use the ID instead of using [ID:]. From the Help file:
  4. @Yodavish Make sure all the functions return a valid handle, otherwise you have a bunch of instructions which you don't know if they're stuck somewhere or just can't select that item in the ListBox
  5. @llssff @Luke94 You can use ExpandVarStrings option too
  6. @dmob Hope this helps you out a little bit: NMHDR; dd (go to the solution). Cheers
  7. Don't tell February or it gets mad P.S.: post what you've tried
  8. @TheXman Thanks for the correction! What can I say... You have an eagle eye!
  9. @ArtoAllan Happy to have helped bud, always a pleasure
  10. The period in Regular Expressions is the meta character for "every character", so, unless you escape it with \, the function is doing its work You don't really need StringRegExpReplace() to do such a simple task; just use StringReplace(), or, if you want to use SRER because you are a cat (you'll probably know in a few posts), then you should do something like this: #include <StringConstants.au3> Test() Func Test() Local $strTest = "715.99" ConsoleWrite(StringRegExpReplace($strTest, '\.', ',') & @CRLF) ConsoleWrite(StringReplace($strTest, '.', ',') & @CRLF) EndFunc
  11. Hi @Sellonis, and a cool welcome to the AutoIt forum! This is one of many flavours (before a cat shows up): ConsoleWrite(ValidatePassword("Someone@something.it", "WhatPasswordIsTh1s@") & @CRLF) ConsoleWrite(ValidatePassword("Someone@something.it", "SomeoneNot@g00dPassword") & @CRLF) ConsoleWrite(ValidatePassword("Address@something.it", "ThisShoulB3aG00dPassword!") & @CRLF) ConsoleWrite(ValidatePassword("Address123@something.it", "ThisShoulB3aG00dPassword!too") & @CRLF) ConsoleWrite(ValidatePassword("AnotherAddress1234@something.it", "ThisPasswordIsT00Long1234567890!!!!!!!!!!!!!!!!!!!!") & @CRLF) Func ValidatePassword($strEmail, $strPassword) Return StringRegExp($strPassword, '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{6,40}$)', $STR_REGEXPMATCH) And _ Not StringRegExp($strPassword, '(?i)' & StringRegExp($strEmail, '([^@]+)@.*', $STR_REGEXPARRAYMATCH)[0], $STR_REGEXPMATCH) EndFunc
  12. @Deye Finally, this pattern works with VBScript. I am a little sad that no cats have shown here to help, but thankfully you and @Nine did your best to support. Thanks again to both of you. Have a nice week-end. Cheers
  13. @Deye Thanks for your help once again. I'll let you know tomorrow if the pattern likes to VBScript; anyway, I made a script with AutoIt to format the data from the file, and it is doing his work as it should, so, I may use that script. Have a good whatever time is there
  14. @Deye Close, but it leaves blank lines at the top of the string. Did you have the same result?
  15. @Deye Thanks for the try, but if you tested the pattern with VBScript, you'll see that it doesn't work. I'd like to kindly remind once again that I'm trying to avoid to use AutoIt for our customer's policies. Thank you
  16. @Nine, @Deye Here I am with a sample file and some tests done. The file uploaded has the same structure that has the original one, but with a lot less information which are not needed to be in the sample file. I made tests with this pattern in AutoIt, and blank lines are left there as they were, while doing the same test with VBScript, they are removed from the source file. Here below, you can find both AutoIt script and VBScript to test with the sample file. Let me know what are your results with the scripts, even if I am quite convinced that VBScript won't be able to bring the same result has AutoIt is doing. As always, a big thanks for both of you! P.S.: Happy fishing AutoIt: #include <FileConstants.au3> #include <StringConstants.au3> Test() Func Test() Local $strFileName = @ScriptDir & "\SECURITY.RPT", _ $hdlFile, _ $strFileContent $hdlFile = FileOpen($strFileName, $FO_READ) If Not $hdlFile Then Return ConsoleWrite("FileOpen ERR: " & $hdlFile & @CRLF) $strFileContent = FileRead($hdlFile) If @error Then Return ConsoleWrite("FileRead ERR: " & @error & @CRLF) $strFileContent = StringRegExpReplace($strFileContent, "(?|User|Login-name|NTSecurity|Member):\s(.*)|.+\v*", "$1") If @error Then Return ConsoleWrite("StringRegExpReplace ERR: " & @error & @CRLF) ConsoleWrite($strFileContent & @CRLF) FileClose($hdlFile) EndFunc VBScript: Dim strFileName: strFileName = "SECURITY.rpt" Dim objFSO Dim objTextStreamIn Dim objTextStreamOut Dim strFileContent Dim objRegEx Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextStreamIn = objFSO.OpenTextFile(strFileName, 1, -1) Set objTextStreamOut = objFSO.CreateTextFile(".\Result.txt") strFileContent = objTextStreamIn.ReadAll objTextStreamIn.Close Set objRegEx = CreateObject("VBScript.RegExp") With objRegEx .Pattern = "(User|Login-name|NTSecurity|Member):\s(.*)|.+\n?" .Global = True .IgnoreCase = False .Multiline = True objTextStreamOut.Write(.Replace(strFileContent, "$2")) End With objTextStreamOut.Close Set objRegEx = Nothing Set objTextStreamOut = Nothing Set objTextStreamIn = Nothing Set objFSO = Nothing SECURITY.RPT
  17. @Deye You are definitely right. I am sorry that I didn't post it yet, but I have been busy all day trying to figure out how to structure the script, and since the file contains only sensitive data, it would have taken a lot to replace it with test data. In fact, what I did post is what I have in the source file, but it's "filtered", and @Nine provided valid patterns which work outside VBScript, but not with it, so, it has nothing to do with data itself; rather, it's something that might be about VBScript. I need to make some tests with AutoIt instead of using VBScript and see if the results are the same, but I already know they won't. I'll let you know as soon as possible. Thanks
  18. @Nine As you can see, the various lines are divided by @CR and @LF, but even with the pattern above, the script returns a string with just @CR @LF after each line, without blank lines as they appears in the original file (image below), so I assume that they're removed. As I said before, AutoIt and VBScript supports different regex motors, and so, what works on AutoIt may not work on VBScript. Thanks for your kind help
  19. @Nine The above pattern returns a string without \n, so data is formatted like this: SomeUser1 SomeLoginName1 YES MemberOfFirstGroup1 MemberOfSecondGroup1 MemberOfThirdGroup1 SomeUser2 SomeLoginName2 YES MemberOfFirstGroup2 instead of: SomeUser1 SomeLoginName1 YES MemberOfFirstGroup1 MemberOfSecondGroup1 MemberOfThirdGroup1 SomeUser2 SomeLoginName2 YES MemberOfFirstGroup2 and doing so, I have no discriminating string to know where a new "group" of information starts (and so, neither where a group of information ends). Fun fact is if I try both patterns with RegEx101.com, I have a different result from VBScript one. Ideally, and based on the result I had from RegEx101.com, every group of information is divided by two \n, and so, I can split those "chunks" in groups which handle one user information, which I then use throughout the script. Thanks again for you help.
  20. @Nine Bad news... Seems that branch reset group is not supported from VBScript, so I currently can't use your solution, even if I already adapted the code to work with that. Is it possible to have the same result without branch reset groups? Thanks for your help
  21. @Nine Definitely yes! Thank you so much for you help, really appreciated I'll flag this thread as solved, but if anyone else (just for fun) want to try another flavours, they are highly appreciated as well. Have a good day!
  22. @Nine Always a pleasure to see you here around I forgot to mention that these information are part of a bigger string, in which there's a lot of data, so, the best solution would be to capture those values instead of removing what is not needed. I like the approach by the way, thanks
  23. Good morning yall! I wonder how could I capture some values which are part of a string, where a particular prefix appears multiple times, with different values after it. This is the input string: User: SomeUser Login-name: SomeLoginName NTSecurity: YES Domain: SomeDomain Timeout: 00:00:00 Member: MemberOfFirstGroup Member: MemberOfSecondGroup Member: MemberOfThirdGroup This is the output it should produce: SomeUser SomeLoginName YES MemberOfFirstGroup MemberOfSecondGroup MemberOfThirdGroup So, practically, the Domain and Timeout parameters are ignored by the pattern, which look like this (without the "Member:" captouring group): User:\s([^\r\n]+)\s* Login\-name:\s([^\r\n]+)\s* .*?\s* NTSecurity:\s([^\r\n]+)\s* I'm using this pattern in VBScript, so I had to change it a bit from AutoIt regex "pattern' style". Could you please enlight me on how to do that? Thanks a lot. Francesco
  24. @Tony007 This function should do what you asking for, as well as the above script that @argumentum kindly posted: Func _RTrimWord($strString) Return StringRegExpReplace($strString, '\s*\S+$', '') EndFunc
×
×
  • Create New...