-
Posts
2,658 -
Joined
-
Last visited
-
Days Won
19
Everything posted by FrancescoDiMuro
-
Pause For loop when lost connection
FrancescoDiMuro replied to dphuc23's topic in AutoIt General Help and Support
ExitLoop -
Extract data from json
FrancescoDiMuro replied to dphuc23's topic in AutoIt General Help and Support
@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 -
Select string from listbox - (Moved)
FrancescoDiMuro replied to Yodavish's topic in AutoIt General Help and Support
@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 -
Select string from listbox - (Moved)
FrancescoDiMuro replied to Yodavish's topic in AutoIt General Help and Support
@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: -
Select string from listbox - (Moved)
FrancescoDiMuro replied to Yodavish's topic in AutoIt General Help and Support
@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 -
Making CmdLine work inside of quotes
FrancescoDiMuro replied to llssff's topic in AutoIt General Help and Support
@llssff @Luke94 You can use ExpandVarStrings option too -
RAGrid grid custom control
FrancescoDiMuro replied to robertocm's topic in AutoIt General Help and Support
@dmob Hope this helps you out a little bit: NMHDR; dd (go to the solution). Cheers -
Don't tell February or it gets mad P.S.: post what you've tried
-
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
-
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
-
@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
-
@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
-
@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
-
@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.
-
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
-
Remove last word from string - (Moved)
FrancescoDiMuro replied to Tony007's topic in AutoIt General Help and Support
@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