Jump to content

Search the Community

Showing results for tags 'parse'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 10 results

  1. Hello, once more I have to see, that my knowledge about XML is too poor, even to use this existing XML UDF If it should be a better approach to make use of StringRegEx, or maybe a totally different approach, any suggestions will be mostly appreciated. I downloaded the ZIP XML_1.1.1.13 and tried to get how to use it from the sample AU3 files included in that ZIP file, well, I don't really get it😵 What I want to do: My mobile phone's backup contain all the contacts in an XML file. This is an example of such a file, backupinfo.xml, shortened to show just one fictive entry: <?xml version="1.0" encoding="utf-8" ?> <ContactRecords> <contact> <structuredName> <displayName>Max Mustermann</displayName> <givenName>Max</givenName> <familyName>Mustermann</familyName> <prefixName /> <middleName /> <suffixName /> <phoneticGivenName /> <phoneticMiddleName /> <phoneticFamily /> </structuredName> <organization> <company>Schlosserei Mustermann GmbH</company> <department /> <title /> </organization> <phones> <phone> <number>07652 881 8181</number> <type>home</type> <customLabel /> </phone> <phone> <number>0 800 435 2758</number> <type>work</type> <customLabel /> </phone> <phone> <number>+49 160 4321 222</number> <type>mobile</type> <customLabel /> </phone> </phones> <emails /> <addresses /> <ims /> <WebSites /> <Events /> <note /> <nickName /> <photo /> <netPhone /> <groups> <group> <groupName>Ungrouped</groupName> </group> </groups> </contact> </ContactRecords> Basically I want to search my mobile's contacts for phone numbers to, to see, what contact they belong to. Propably it will make the task much more easy, when standardizing the mobile's contact XML to hold all numbers in "international-notation-without-any-whitespaces" (thats no problem): <?xml version="1.0" encoding="utf-8" ?> <ContactRecords> <contact> <structuredName> <displayName>Max Mustermann</displayName> <givenName>Max</givenName> <familyName>Mustermann</familyName> <prefixName /> <middleName /> <suffixName /> <phoneticGivenName /> <phoneticMiddleName /> <phoneticFamily /> </structuredName> <organization> <company>Schlosserei Mustermann GmbH</company> <department /> <title /> </organization> <phones> <phone> <number>+4976528818181</number> <type>home</type> <customLabel /> </phone> <phone> <number>+498004352758</number> <type>work</type> <customLabel /> </phone> <phone> <number>+491604321222</number> <type>mobile</type> <customLabel /> </phone> </phones> <emails /> <addresses /> <ims /> <WebSites /> <Events /> <note /> <nickName /> <photo /> <netPhone /> <groups> <group> <groupName>Ungrouped</groupName> </group> </groups> </contact> </ContactRecords> What I would like to get from the XML file as a result, e.g. searching the phone number "+491604321222" Present in XML or not (true) if present then return the values for... type (mobile) givenname (Max) familyname (Mustermann) company (Schlosserei Mustermann GmbH) optional: Other node names and their values within that contact, when not "empty" (like in this examle <emails /> or <middlename />) The values from #2 - #6 would be perfect when returned in a 2D Array, Col0 = name, Col1 = value. Regards, Rudi.
  2. Greetings, Someone can help-me to translate this Python's code to AutoIt? Python (source: https://repl.it/repls/InstructiveDarkslategreyJackrabbit) str = 'age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!"' key = "" val = "" dict = {} parse_string = False parse_key = True # parse_val = False for c in str: print(c) if c == '"' and not parse_string: parse_string = True continue elif c == '"' and parse_string: parse_string = False continue if parse_string: val += c continue if c == ',': # terminate entry dict[key] = val #add to dict key = "" val = "" parse_key = True continue elif c == '=' and parse_key: parse_key = False elif parse_key: key += c else: val+=c dict[key] = val print(dict.items()) Python's output: [('phrase', "I'm cool!"), ('age', '12'), ('name', 'bob'), ('hobbies', 'games,reading')] AutoIt #include-once #include <Array.au3> #include <StringConstants.au3> Global $opt $opt = "estado = """" , cep = """", idade=32, nome = ""Luismar"", campo=""campo = campo""" $opt = "age=12,name=bob,hobbies=""games,reading"",phrase=""I\'m cool!""" ConsoleWrite($opt & @LF) Local $arr = StringSplit($opt, "", $STR_CHRSPLIT) Local $key = "" Local $val = "" Local $dict = ObjCreate("Scripting.Dictionary") Local $parse_string = False Local $parse_key = True Local $c For $ii = 1 To $arr[0] $c = $arr[$ii] If $c == '"' And Not $parse_string Then $parse_string = True ContinueLoop ElseIf $c == """" And $parse_string Then $parse_string = False ContinueLoop EndIf If $parse_string Then $val &= $c ContinueLoop EndIf If $c = "," Then $dict.Add($key, $val) $key = "" $val = "" $parse_key = True ContinueLoop ElseIf $c == "=" And $parse_key Then $parse_key = False ElseIf $parse_key Then $key &= $c Else $val &= $c EndIf Next $dict.Add($key, $val) ; missing this line... For $each In $dict ConsoleWrite($each & " = " & $dict.Item($each) & @LF) Next AutoIt's output age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!" age = 12 name = bob hobbies = games,reading Best regards.
  3. The McAfee return for AV defs per "C:\Progra~1\Common~1\McAfee\SystemCore\csscan.exe -Versions" is ... CommonShell Command Line Scanner Lite (VSCORE.15.5.0.3960) Engine version: 5800.7501 DAT version: 8450.0 Time required: 15 milliseconds I want to isolate the actual DAT version as "8450.0". There may be an easier way to get the DAT Version via other McAfee or registry methods but essentially I just want to know how to parse a string at a character or @CRLF into two separate strings for further parsing. Example: $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" Parse into $var1 = "Name" & $var2 = "Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" From there I'd like to parse $var2 at "|" into $var3 = "Microsoft Windows 10 Professional" and $var4 "C:\windows|\Device\Harddisk0\Partition2"
  4. My script currently reads a text file line by line. I want it to look for this the chat message below and skip the session messages. There are some garbage lines that I want it to skip over. So if a line doesnt match that format then skip it. I tried experimenting with StringRegExp but I think I'm using it wrong. Heres my code If StringRegExp($read, '\W\d\d\w\d\d\D.\W') = Not @error Then I was hoping that this would be able to see the open bracket, 2 digits, a colon, 2 digits, close bracket, a space and a <. But it doesn't seem to be working. Eventually I want to be able to extract the username and chat message into separate strings but I haven't got that far yet.
  5. Here is another WMIC script that parses properties from various alias classes. ie: COMPUTERSYSTEM, CDROM, IDECONTROLLER, DISKDRIVE, etc. Download: WMIC_GET.au3
  6. I have another AutoIT script making a Log file Sample of Log file: 2016/08/22 12:44:18 > Process: [RUNNING] [ACTIVE] 2016/08/22 12:48:35 > Process: [WAS NOT RUNNING] 2016/08/22 13:40:00 > Process: [FAILED] 2016/08/22 14:01:10 > Process: [WAS NOT RUNNING] I am looping through the Log file for the word "FAILED" I then want to get all lines that have "FAILED" and get their TIME My Current code to get this far: If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents,$search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog,$i) If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf Else ConsoleWrite( $search & " not found!" & @CRLF) EndIf Next EndIf EndIf For this part: If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf OUTPUT: 2016/08/22 13:40:00 > Process: [FAILED] I dont understand how I read the time in that output? I have tried _DateTimeFormat - Dont think this applies Tried _DateDiff - I dont have a the date yet so this doesnt work Would love if someone could tell me if I am thinking is the wrong direction and possibly lead me down the correct path to light side of the force
  7. Hi, is there a function or a UDF for parsing a hotkey definition string like "^a" or "+!{F1}" ? I´d like to create a settings GUI where users are able to define their custom hotkeys for a specific function and then save it to an ini. Of course, at the next start of the program, these settings have to read and not only the HotkeySet() command needs to be fed with it but also the settings GUI. As I do not want to present the user just the hotkey string but a rather user-friendly display (like checkboxes for the separate modifier keys and a drop down list of supported trigger keys), I need to fiddle on the saved string. I would envision a function that takes a hotkey string and returns for example an array like this: [isCtrl][isAlt][isShift][isWin][triggerKey][isTriggerVirtual]. And of course, there needs to be a function decoding the array back to the respective string representation. Thanks for your hints!
  8. Hello, I am not sure where to start on this, but maybe some help from the community will help. I understand how to open a file and read it with autoit. My issue is this, I need to be able to select all the data on certain lines of the file by a keyword. I have a file that has multiple lines with the word "proxyAddresses:" that starts at the beginning of each line I want, there are other lines with other information I do not want. How can I select what I want and put it into an array? Example of file dn: CN=John Doe,OU=Techs,OU=Users,DC=foo,DC=bar changetype: add objectClass: top objectClass: person objectClass: organizationalPerson objectClass: user proxyAddresses: X500:/o=FooBar/ou=Exchange Administrative Group (FYDI)/cn=Re cipients/cn=Jogn Doec52 proxyAddresses: x500:/o=ExchangeLabs/ou=Exchange Administrative Group (FYSPDLT)/cn=Rec ipients/cn=3ab8cd9xxxxxxxxxxxxxxxxxxxxxf64e0c-John Do proxyAddresses: sip:jdoe@foobar.com proxyAddresses: smtp:jdoe@foobar.mail.onmicrosoft.com proxyAddresses: SMTP:jdoe@foobar.com
  9. Hi Guys, I'm trying to find a way to collect data from a webpage using IE. I already know about _IEBodyReadText($oIE) but the problem is, I just want a specific instance of that text without getting all of it. What I want to be able to do, is to read that text line by line, and when I find a specific string on the line I want, I want to be able to print out that entire line. The problem for me is that It _IEBodyReadText formats the text into one big string, so I would have to use split string to accomplish this task. The problem with that is, there are no lines, so I don't know how I would write something like, if substring=Cluster read untill you reach .com, and let that be the substring.... Should I tackle this problem that way, or should I find a way to get the substring I want from the HTML itself? Thanks, Athos
  10. I forgot to update this, I had responded to a topic with an updated PCRE for parsing individual items/options, so here's the updated code: _StringParseParameters: Parse Parameters in a string: Returns an array as if a command-line parser split the elements, or if nothing found an @error. Note there is a look-behind and look-ahead assertion to prevent grabbing quotes, while also allowing for cases where there are empty quotes (""): Local $aParsedArray=StringRegExp($sStringToParse,'((?<=\s"|^")[^"]+(?=")|[^\s"]+)',3) The only thing I'd do beforehand is expand any environment strings like %windir%. All you'd need for that is to just set the "ExpandEnvStrings" option, assign the string to itself (looks dumb, but accomplishes the needed expansion), then reset the option. (or call the ExpandEnvironmentStrings API function) The old version of this can still be found in a post I had made in the thread ' - it also parses comma-separated arguments, though retaining quotes. That could easily be remedied though.
×
×
  • Create New...