mist3r Posted January 10, 2007 Share Posted January 10, 2007 Hey, I've read into the String functions and cant quite figure out how to go about removing everything in a string after a certain character. Basically so far the script runs pstools and saves the outcome to a text file. Its then read line by line and I retreive the data I need In the text file it returns "Kernel version: Microsoft Windows XP, Uniprocessor Free". Im looking to replace all the characters after the ','. Is the only way by doing a StringReplace on the 'Uniprocessor Free' with ' '? Im not sure what other outcome's there will be if ran on different machines and therefore can't do a StringReplace on strings that might vary from machine to machine. Any help or advice much appreciated Thanks Link to comment Share on other sites More sharing options...
xcal Posted January 10, 2007 Share Posted January 10, 2007 Well, you can do it like this... $string = 'Kernel version: Microsoft Windows XP, Uniprocessor Free' $newstring = StringLeft($string, StringInStr($string, ',')-1) MsgBox(0, '', $newstring) ...but not sure if it'll work on other machines. Is the string always formatted 'some text: some text, some text'? How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
mist3r Posted January 10, 2007 Author Share Posted January 10, 2007 (edited) aah, excellent. Thanks for that. I've been thinking for aaaaages wondering how to go about it. Saved me alot of hassle. Thanks mate. I don't suppose you've ever had any problems with "GUICtrlCreateEdit" when the Window also has a bg image? $GUI = GUICreate("ms.Support", 500, 350) $GuiGraphic = GUICtrlCreatePic("Assets\bgCompInfo.jpg", 0, 0, 500, 350) GUISetState(@SW_SHOW) ;pstools RunWait(@ComSpec & ' /c ' & 'tools\psinfo.exe > psinfo.txt', @ScriptDir, @SW_HIDE) $file = FileOpen(@ScriptDir & "\psinfo.txt", 0) $cpuTypeLine = FileReadLine($file, 16) $cpuTypeLine = StringTrimLeft(StringStripWS($cpuTypeLine, 4),16) $cpuNumberLine = FileReadLine($file, 14) $cpuNumberLine = StringTrimLeft(StringStripWS($cpuNumberLine, 4),12) $cpuSpeedLine = FileReadLine($file, 15) $cpuSpeedLine = StringTrimLeft(StringStripWS($cpuSpeedLine, 4),17) $memTotalLine = FileReadLine($file, 17) $memTotalLine = StringTrimLeft(StringStripWS($memTotalLine, 4),17) $osVersion = FileReadLine($file, 3) $osVersion = StringTrimLeft(StringStripWS($osVersion, 4),16) $osVersion = StringLeft($osVersion, StringInStr($osVersion, ',')-1) ;AutoIt Variables $compName = @ComputerName $compOSType = @OSTYPE $compBuild = @OSBuild $compSP = @OSServicePack ;Forms $cpuTypeInput = GUICtrlCreateInput("" & $cpuTypeLine , 20, 150, 180, 18) $cpuNumberInput = GUICtrlCreateEdit("" & $cpuNumberLine , 20, 170, 20, 18) $cpuSpeedInput = GUICtrlCreateEdit("" & $cpuSpeedLine , 20, 190, 150, 18) $cpuSpeedInput = GUICtrlCreateEdit("" & $memTotalLine , 20, 210, 80, 18) $osInfo = GUICtrlCreateEdit(" " & $compName & " " & $osVersion & " " & $compBuild & " " & $compSP, 20, 240, 300, 18) Basically, when it runs it fetches the variables fine and shows them in editable boxes. But when theres an image used, you can't click in the box's to edit them, yet you can if you press TAB to get to them. Works fine as soon as I take the GUICtrlCreatePic out. ** Actually found that answer.. again i'd been searching for ages and all along it wasnt the editable boxes, rather the bg settings. I used GUICtrlSetState(Default, $GUI_DISABLE) which seems to make it work. ** Thanks again mate Edited January 10, 2007 by mist3r 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