RichardT Posted April 21, 2010 Share Posted April 21, 2010 Hello Everyone,I have something very basic I need done. But I am new to AutoIT, and I would love to include it into a script i am using to install WLAN profiles con computers. The text output I get from the file is:<*****>There are 1 interfaces in the system.Interface 0: GUID: 70768bfc-d0e8-4630-a985-8843575194af Atheros AR5007EG Wireless Network Adapter - Packet Scheduler Miniport State: "connected"Command "ei" completed successfully.<*****>I need to extract out the GUID number only. Every system I run this on, will have a seperate GUID number. I need to capture it, make it a variable, and then use it a couple of times.I tried using the FileReadLine option, but I kept getting everything else on the line except just the number.Any Ideas? "so much work, so little brains..." Link to comment Share on other sites More sharing options...
trancexx Posted April 21, 2010 Share Posted April 21, 2010 Maybe$sString = "Interface 0:" & @CRLF & _ "GUID: 70768bfc-d0e8-4630-a985-8843575194af" & @CRLF & _ "Atheros AR5007EG Wireless Network Adapter - Packet Scheduler Miniport" ; $sString = FileRead($sThatFile) ConsoleWrite(_ExtractGUID($sString) & @CRLF) Func _ExtractGUID($sString) Local $aArray = StringRegExp($sString, "GUID:\h*([[:xdigit:]]{8}-([[:xdigit:]]{4}-){3}[[:xdigit:]]{12})", 3) If @error Then Return SetError(1, 0, "") Return $aArray[0] EndFunc ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Yoriz Posted April 21, 2010 Share Posted April 21, 2010 (edited) or maybe #Include <File.au3> #Include <Array.au3> Global $aArray, $sFilePath = "Yourfilepath here") _FileReadToArray ($sFilePath, $aArray) $iPos = _ArraySearch ($aArray, "GUID:", 0, 0, 0, 1) $aSplit = StringSplit($aArray[$iPos], "GUID:", 1) $swhatyouwant = $aSplit[2] MsgBox(0,"",$swhatyouwant) Edited April 21, 2010 by Yoriz GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
RichardT Posted April 21, 2010 Author Share Posted April 21, 2010 Thanks for the fast response! But will these examples work if the number keeps changing? example: This files has a GUID number of 70768bfc-d0e8-4630-a985-8843575194af, but the next will will be completely different. I don't need the word "GUID", just the number. So if I understand the clips that Yoriz and trancexx gave me, it would always look for the same number? or a "place setting" for all future ones. All the file outputs I get, will have this same format, just different numbers. I probably need more medication to grasp this. "learn me 'ol wise ones" "so much work, so little brains..." Link to comment Share on other sites More sharing options...
Fulano Posted April 21, 2010 Share Posted April 21, 2010 Just a comment on their methods: Trancexx is looking for groups of hex numbers, so a group of 8, followed by a dash, then a group of 4 hex digits and so on Yoriz is looking for the string 'GUID: ', and then capturing everything after that marker. Hope this helps you understand their code #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
RichardT Posted April 21, 2010 Author Share Posted April 21, 2010 Jeez! Thats brilliant! Thanks for helping! "so much work, so little brains..." Link to comment Share on other sites More sharing options...
RichardT Posted April 21, 2010 Author Share Posted April 21, 2010 When I try to run tracexx's version, I get the following errors:C:\file.au3(4,31) : ERROR: syntax error_FileReadToArray ($sFilePath, ByRef~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\file.au3(4,44) : ERROR: _FileReadToArray() called with Const or expression on ByRef-param(s)._FileReadToArray ($sFilePath, ByRef $aArray)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Program Files\AutoIt3\Include\File.au3(192,49) : REF: definition of _FileReadToArray().Func _FileReadToArray($sFilePath, ByRef $aArray)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\file.au3 - 2 error(s), 0 warning(s)I put $sFilePath = "C:\test.txt" declaring the var. "so much work, so little brains..." Link to comment Share on other sites More sharing options...
Yoriz Posted April 21, 2010 Share Posted April 21, 2010 Looks more like part of my code, i never actually run it i just copied some functions out of the helpfile, hence the byref being in there, ive updated my post deleting the unessary byref. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
RichardT Posted April 22, 2010 Author Share Posted April 22, 2010 Sorry, you are right. I suck at getting names right. But your code works great now! thanks so much... "so much work, so little brains..." 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