parasoul
23rd February 2011 21:41 UTC
Finding Steam ID
Hello,
I am currently trying to use this code to find the steam ID:
Section
ClearErrors
FileOpen $0 "$PROGRAMFILES\Steam\steam.log" r
${Do}
FileRead $0 $1
${If} ${Errors}
${ExitDo}
${EndIf}
StrCpy $2 "$2$1"
${Loop}
FileClose $0
; contents should now be in $2:
MessageBox MB_OK "Contents: $\r$2"
;${StrFilter} $2 "31" "1234567890" "(){}.-" $R0
${WordFind} $2 "0:1:" "+8" $R0
MessageBox MB_OK "SteamID: $\r$R0"
SectionEnd
The steam ID is contained in steam.log in the following context:
CsComm Session Oct-11-2010 23:07:41.780 [2904] ReconnectThread (2904) Starting
CsComm Session Oct-11-2010 23:08:31.454 [4368] CreateSession(xxxxx,7,347)=0 attempt 1
CsComm ConnectionPool Oct-11-2010 23:08:31.851 [4368] Attempting new connection 0,87.248.222.122:27030 for 0:1:55555555
so you see my dilemma of trying to exclude my output to just the
55555555 after the "0:1:"
WordFind isn't filtering or excluding anything from the string which I'd like it to.
Any help would be appreciated. Thanks!
Afrow UK
23rd February 2011 23:58 UTC
You can't get this from the registry?
Edit: Ok it's not in there. The problem you are having here is probably due to the 1024 char limit. Why are you concatenating all the lines anyway? Just iterate through each line until you find the one that has "CsComm" followed by "ConnectionPool".
Stu
parasoul
24th February 2011 02:47 UTC
Originally posted by Afrow UK
You can't get this from the registry?
Edit: Ok it's not in there. The problem you are having here is probably due to the 1024 char limit. Why are you concatenating all the lines anyway? Just iterate through each line until you find the one that has "CsComm" followed by "ConnectionPool".
Stu
Can you provide an example of that? I'm not quite sure how to do that in NSIS.
I came up with this:
Section
ClearErrors
FileOpen $0 "$PROGRAMFILES\Steam\steam.log" r
${Do}
FileRead $0 $1
${If} ${Errors}
${ExitDo}
${EndIf}
StrCpy $2 "$2$1"
${Loop}
FileClose $0
; contents should now be in $2:
MessageBox MB_OK "Contents: $\r$2"
;${StrFilter} $2 "31" "1234567890" "(){}.-" $R0
${StrStr} $R0 $2 "0:0:"
Pop $R1
${If} $R1 != ""
Goto finishsid
${ElseIf} $R1 == ""
${StrStr} $R0 $2 "0:1:"
;$R0 = "No Steam ID Found"
${EndIf}
;${WordFind} $R0 "$\n" "-8{" $R0
finishsid:
FileOpen $5 "$TEMP\sid.tmp" w
FileWrite $5 $R0
FileClose $5
${LineRead} "$TEMP\sid.tmp" "1" $R0
MessageBox MB_OK "SteamID: $\r$R0"
SectionEnd
it's slow, but it works. There's a 90-100% chance that the steam ID will be included in the first 10 or so lines of the log, which is what the concatenated string I'm creating contains.
I'd love a more optimal way to do it if it, if you have an example of what you're talking about laying around
thanks Stu :up: