sonicxtacy02 Posted June 21, 2006 Share Posted June 21, 2006 (edited) I'm looking to make a script that will execute a command if the text CMGW is found in a .txt file. Can autoit read information from text files? Also i'd need help with setting up a variable based on the information found in the text file. For example if the text file reads CMGW=963 i'd need to make the script aware that 963 is a variable that i'll need to use later and not just a stated value. Thanks! Edited June 21, 2006 by sonicxtacy02 Link to comment Share on other sites More sharing options...
w0uter Posted June 21, 2006 Share Posted June 21, 2006 yes. (search the helpfile) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Bundy Posted June 21, 2006 Share Posted June 21, 2006 Look at commands: FileRead FileReadLine IniRead Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted June 22, 2006 Author Share Posted June 22, 2006 Look at commands:FileReadFileReadLine IniReadI looked at those and while they do read from the file they cant search for specific text within the file. I want the script to read from a programs log file that gets updated in real time. I need the script to continuously check for the text "CMGW=". If the text is found, a command is run. The text isnt going to be in the same place everytime the file is read so i cant specify a section or line of the file to read. Link to comment Share on other sites More sharing options...
Simucal Posted June 22, 2006 Share Posted June 22, 2006 StringInStr() the variable that has what FileRead outputs, in a loop. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Skruge Posted June 22, 2006 Share Posted June 22, 2006 First off, welcome to the forums. Second, please read the help file. After you use one of the functions mentioned above, you still have to process the file. You'll probably need StringInStr(), While/Wend, and Run()/RunWait(). Good luck! [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted June 22, 2006 Author Share Posted June 22, 2006 First off, welcome to the forums. Second, please read the help file. After you use one of the functions mentioned above, you still have to process the file. You'll probably need StringInStr(), While/Wend, and Run()/RunWait(). Good luck! I appreciate the assistance. I understand loops and how to execute the command. I'm having trouble with the StringInStr section. I understand what it does, however i dont understand how to have the entire contents of the text file as the string (or if it really needs to be the entire file). This is what i have so far. I know the run command hasnt been added just tryin to take care of this section at a time While ProcessExists("PhoneCTL.NET.exe") if FileExists("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") FileOpen("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") sleep(3000) fileread("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") StringInStr("CMGW=*","CMGW=*") Else EndIf Wend 2 questions now. Can the string be the same as the substring? Lastly, will the * denote a wildcard and receive whatever integer thats behind the CMGW=? Link to comment Share on other sites More sharing options...
randallc Posted June 22, 2006 Share Posted June 22, 2006 (edited) Hi, you only need to search for the text you are looking for ; no wildcards needed While ProcessExists("PhoneCTL.NET.exe") if FileExists("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") then $h_FileHandle=FileOpen("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") If @error = -1 Then ExitLoop $s_FileTextTotal=fileread($h_FileHandle); filename will owrk if StringInStr($s_FileTextTotal,"CMGW=") then MsgBox(0,"","'CMGW=' occurs in the text string from file read PhoneCtlLog.txt") fileclose($h_FileHandle) Else EndIf WendUse the helpfile examples to base your script, and you won't miss the "then", the "fileclose", the handle name , the @error call, the string variable name etc! Best, Randallc Edited June 22, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
ivan Posted June 22, 2006 Share Posted June 22, 2006 (edited) Try opening a file handle and then assigning what was read to a variable, say $filehandle=FileOpen("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt",0) $var=fileread($filehandle) then you need a condition to check for the string "CMGW=*" in the $var, such as if StringInStr($var, "CMGW=*") then code endif hope this helps I appreciate the assistance. I understand loops and how to execute the command. I'm having trouble with the StringInStr section. I understand what it does, however i dont understand how to have the entire contents of the text file as the string (or if it really needs to be the entire file). This is what i have so far. I know the run command hasnt been added just tryin to take care of this section at a time While ProcessExists("PhoneCTL.NET.exe") if FileExists("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") FileOpen("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") sleep(3000) fileread("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") StringInStr("CMGW=*","CMGW=*") Else EndIf Wend 2 questions now. Can the string be the same as the substring? Lastly, will the * denote a wildcard and receive whatever integer thats behind the CMGW=? Edited June 22, 2006 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted June 22, 2006 Author Share Posted June 22, 2006 (edited) i do need a wildcard. The actual text i need to search for will be "CMGW=****" where **** is 3-4 digit number. Each time CMGW= appears in the text file the value changes. This value is what actually NEEDS to be read because the run command will need to state this value. For instance, if CMGW=1144 my run command will need to send AT+CMSS=1144 to the phonecontrol program thru its remote interface. Once the value of CMGW is found i'm hoping to be able to make the value a variable. I'll try both methods suggested to see how well it reads the text i need. Thanks! Edited June 22, 2006 by sonicxtacy02 Link to comment Share on other sites More sharing options...
randallc Posted June 22, 2006 Share Posted June 22, 2006 hi, Sorry, I missed that; you get the character pos frim (stringinstr) and then read the subsequent 3 or 4 chars (the checking will differ depending on where the 3 digits are if there are not 4!) While ProcessExists("PhoneCTL.NET.exe") if FileExists("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") then $h_FileHandle=FileOpen("C:\Program Files\Phonecontrol.NET\PhoneCtlLog.txt") If @error = -1 Then ExitLoop $s_FileTextTotal=fileread($h_FileHandle); filename will owrk $location = StringInStr($s_FileTextTotal,"CMGW=") if $location then $s_variable=stringmid($s_FileTextTotal,$location+5,4) if not IsNumber(StringRight($s_variable,1)) then $s_variable=stringmid($s_FileTextTotal,$location+5,3); check?? $i_number=number($s_variable) MsgBox(0,"","'CMGW=' occurs in the text string from file read PhoneCtlLog.txt at character= "&$location) MsgBox(0,"","number derived from 4 characters after 'CMGW='"&$i_number) fileclose($h_FileHandle) EndIf Else EndIf WendRandallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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