gcue Posted September 11, 2008 Author Share Posted September 11, 2008 it's actuallly a hard return, because if i put text after the value it comes on the next line im using stringtrimright($RegArray[$u], 1) for both values in the for loop - and they look good. what syntax can i use outside of the loop to get rid of the trailing value on each variable ($RegArray and $SerArray)? Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 it's actuallly a hard return, because if i put text after the value it comes on the next line im using stringtrimright($RegArray[$u], 1) for both values in the for loop - and they look good. what syntax can i use outside of the loop to get rid of the trailing value on each variable ($RegArray and $SerArray)?Thats the thing, is I put a stringtrimright() in the function and it dropped the last character from each entry which was not a space, so I am unsure where you are seeing the space.... can you show me? Post a piece of code that shows the space and I will try to help. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 (edited) when i do the for loop here: For $u = 1 To $RegArray[0] RegRead("\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u] & "\control", "") If @error <> 1 Then MsgBox(0, "", $SerArray[$u] & " is a monitor in use.") EndIf Next the path was not found, so i did this: For $u = 1 To $RegArray[0] msgbox(0, "", $RegArray[u] & "\control") msgbox(0, "", $SerArray[u] & "\control") Next and saw that "\control" was starting on a new line with both values Edited September 11, 2008 by gcue Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 I am sorry, but I am still unable to see a space or break in there anywhere... Here is my reproducer of me NOT seeing it: #include<array.au3> #include<file.au3> Local $array RunWait(@ComSpec & ' /c ' & FileGetShortName(@ScriptDir & '\dumpedid.exe') & ' > "' & @TempDir & '\dumpedidTEMP.txt"', @SystemDir, @SW_HIDE) $RegArray = DumpedidFileToArray(@TempDir & '\dumpedidTEMP.txt', "Registry Key : ") $SerArray = DumpedidFileToArray(@TempDir & '\dumpedidTEMP.txt', "Serial Number : ") $teststring = '' For $u = 1 To $RegArray[0] $teststring &= "\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u] & "\control" If $u <> $RegArray[0] Then $teststring &= @CRLF Next If FileExists( @TempDir & "\teststring.txt" ) Then FileDelete( @TempDir & "\teststring.txt" ) FileWrite( @TempDir & "\teststring.txt", $teststring ) ShellExecute( "notepad", @TempDir & "\teststring.txt" ) Func DumpedidFileToArray($file, $searchstring) Dim $temparray, $filterarray[1] _FileReadToArray( $file, $temparray) For $a = 1 To UBound($temparray) - 1 If StringInStr($temparray[$a], $searchstring) Then _ArrayAdd( $filterarray, StringReplace($temparray[$a], $searchstring, '') ) Next $filterarray[0] = UBound($filterarray) - 1 Return $filterarray EndFunc ;==>DumpedidFileToArray Can you please post a reproducer of you seeing it? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 not sure what u mean by reproducer.. would you be able to tell me where i can do the stringtrim outside of the for loop? otherwise i can just leave it in the for loop (didnt want to cause its definitely dirtier) hehe thanks! Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 I would suggest putting it into the function, but when I do that it trims the last character off of the end of the string. Show me your full script with it showing the space in the string is what I meant by reproducer.. BRB... Meeting... AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 entire script many thanks! i think bc our outputs are different.. the file i sent before was my output expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=clipboard.ico #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <array.au3> #include <file.au3> Local $array $file = (@TempDir & '\dumpedidTEMP.txt') RunWait(@ComSpec & ' /c ' & FileGetShortName(@ScriptDir & '\dumpedid.exe \\d0075931') & ' > "' & $file);, @SystemDir);, @SW_HIDE) $RegArray = DumpedidFileToArray($file, "Registry Key : ") _ArrayDisplay($RegArray) $SerArray = DumpedidFileToArray($file, "Serial Number : ") _ArrayDisplay($SerArray) Func DumpedidFileToArray($file, $searchstring) Dim $temparray, $filterarray[1] _FileReadToArray( $file, $temparray) For $a = 1 To UBound($temparray) - 1 If StringInStr($temparray[$a], $searchstring) Then _ArrayAdd( $filterarray, StringReplace($temparray[$a], $searchstring, '') ) Next $filterarray[0] = UBound($filterarray) - 1 Return $filterarray EndFunc ;==>DumpedidFileToArray For $u = 1 To $RegArray[0] $reg = StringTrimRight($RegArray[$u], 1) $serial = StringTrimRight($SerArray[$u], 1) ;RegRead("\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u] & "\control", "") RegRead("\\d0075931\hklm\system\controlset001\enum\" & $reg & "\control", "") ;~ If @error <> 1 Then ;~ MsgBox(0, "", $SerArray[$u] & " is a monitor in use.") ;~ EndIf If @error <> 1 Then MsgBox(0, "", $serial & " is a monitor in use.") EndIf Next Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 (edited) This was working for me on a local machine... try it out for your remote d0075931 machine #include <array.au3> #include <file.au3> Local $array $file = (@TempDir & '\dumpedidTEMP.txt') RunWait(@ComSpec & ' /c ' & FileGetShortName(@ScriptDir & '\dumpedid.exe \\d0075931') & ' > "' & $file);, @SystemDir);, @SW_HIDE) $RegArray = DumpedidFileToArray($file, "Registry Key : ") $SerArray = DumpedidFileToArray($file, "Serial Number : ") For $u = 1 To $RegArray[0] If MonInUse("\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u]) Then MsgBox(0, "", $SerArray[$u] & " is a monitor in use.") Next Func MonInUse($RegKey) $a = 1 While 1 $key = RegEnumKey($RegKey, $a) If @error Then ExitLoop If $key = "Control" Then Return True $a += 1 WEnd Return False EndFunc ;==>MonInUse Func DumpedidFileToArray($file, $searchstring) Dim $temparray, $filterarray[1] _FileReadToArray( $file, $temparray) For $a = 1 To UBound($temparray) - 1 If StringInStr($temparray[$a], $searchstring) Then _ArrayAdd( $filterarray, StringReplace($temparray[$a], $searchstring, '') ) Next $filterarray[0] = UBound($filterarray) - 1 Return $filterarray EndFunc ;==>DumpedidFileToArray EDIT: I still do not see a trailing space, but I think I know where you were hitting a brick wall: RegRead("\\d0075931\hklm\system\controlset001\enum\" & $reg & "\control", "") You were reading a default value that had no value set.... I am not sure if this is expected behavior or not but it was causing RegRead to error out. I will be posting a thread on this to find out if it's a bug or not. Let me know how it goes for you Edited September 11, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 ya the script above still doesnt work..its a combination of that + the trailing space or hard returnhelp file says:"To access the (Default) value use "" (a blank string) for the valuename."Failure: Returns "" and sets the @error flag: 1 if unable to open requested key 2 if unable to open requested main key 3 if unable to remote connect to the registry -1 if unable to open requested value -2 if value type not supportedso i check the existance of the "control" subkey.. that passes but i get an error for the value "control" which is expected and i handle with the if @error <> 1many thanks again for your help. Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 Ok, updated Autoit to latest version... now I see the issue, sorry about that. When I ran on my old version, the key string did not contain a CR like it does now. Anyways, I just used StringStripCR() to solve the issue (i hope) #include <array.au3> #include <file.au3> Local $array $file = (@TempDir & '\dumpedidTEMP.txt') RunWait(@ComSpec & ' /c ' & FileGetShortName(@ScriptDir & '\dumpedid.exe \\d0075931') & ' > "' & $file);, @SystemDir);, @SW_HIDE) $RegArray = DumpedidFileToArray($file, "Registry Key : ") $SerArray = DumpedidFileToArray($file, "Serial Number : ") For $u = 1 To $RegArray[0] If MonInUse("\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u]) Then MsgBox(0, "", $SerArray[$u] & " is a monitor in use.") Next Func MonInUse($RegKey) $a = 1 While 1 $key = RegEnumKey(StringStripCR($RegKey), $a) If @error Then ExitLoop If $key = "Control" Then Return True $a += 1 WEnd Return False EndFunc ;==>MonInUse Func DumpedidFileToArray($file, $searchstring) Dim $temparray, $filterarray[1] _FileReadToArray( $file, $temparray) For $a = 1 To UBound($temparray) - 1 If StringInStr($temparray[$a], $searchstring) Then _ArrayAdd( $filterarray, StringReplace($temparray[$a], $searchstring, '') ) Next $filterarray[0] = UBound($filterarray) - 1 Return $filterarray EndFunc ;==>DumpedidFileToArray AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 works! but the $SerARRay still has the CR =) Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 OK, last one then (again, I hope LOL) I put the StringStripCR() into the 'DumpedidFileToArray' function #include <array.au3> #include <file.au3> Local $array $file = (@TempDir & '\dumpedidTEMP.txt') RunWait(@ComSpec & ' /c ' & FileGetShortName(@ScriptDir & '\dumpedid.exe \\d0075931') & ' > "' & $file);, @SystemDir);, @SW_HIDE) $RegArray = DumpedidFileToArray($file, "Registry Key : ") $SerArray = DumpedidFileToArray($file, "Serial Number : ") For $u = 1 To $RegArray[0] If MonInUse("\\d0075931\hklm\system\controlset001\enum\" & $RegArray[$u]) Then MsgBox(0, "", $SerArray[$u] & " is a monitor in use.") Next Func MonInUse($RegKey) $a = 1 While 1 $key = RegEnumKey($RegKey, $a) If @error Then ExitLoop If $key = "Control" Then Return True $a += 1 WEnd Return False EndFunc ;==>MonInUse Func DumpedidFileToArray($file, $searchstring) Dim $temparray, $filterarray[1] _FileReadToArray( $file, $temparray) For $a = 1 To UBound($temparray) - 1 If StringInStr($temparray[$a], $searchstring) Then _ArrayAdd( $filterarray, StringStripCR(StringReplace($temparray[$a], $searchstring, ''))) Next $filterarray[0] = UBound($filterarray) - 1 Return $filterarray EndFunc ;==>DumpedidFileToArray AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 perfect!!! MANY thanks danwilli =D Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Share Posted September 11, 2008 Any time, sorry it took this long... first I was on a different version so I wasn't on the same page as you with the @CR issue, then I started asking all kinds of questions to myself about reading a regkey's default value with no data in it to see if it existed.Glad we got it working correctly though, and thanks for not giving up on me LOL AutoIt3 Online Help Link to comment Share on other sites More sharing options...
gcue Posted September 11, 2008 Author Share Posted September 11, 2008 hehe hopefully it will come in handy for you in future projects =) 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