Jump to content

[Solved] Variable returning unexpected result (Can't append value to variable)


Recommended Posts

So here's the script

$sBinaryVideoPath = RegRead("HKEY_CURRENT_USER\SOFTWARE\NVIDIA Corporation\Global\ShadowPlay\NVSPCAPS", "DefaultPathW") ;Value = 0x43003A005C00550073006500720073005C0062006500740061006C005C004F006E006500440072006900760065005C0044006F00630075006D0065006E00740073005C0056006900640065006F0073000000
$sVideoPath = BinaryToString($sBinaryVideoPath, 2)
$sVideoPath &= "\TEST"
InputBox("","",$sVideoPath)

This gets the folder that Nvidia ShadowPlay saves its videos to. Don't worry if you don't have ShadowPlay Installed, just replace $sBinaryVideoPath with the commented value.

Then it converts the binary string to a regular string so we can read and use it.

Then I append "\TEST" to the end of that string.

Finally I display the variable.

 

The problem is it won't append anything to the end of the variable once it is assigned. I can prepend something to this string but appending fails for some reason. Can someone help me figure out this issue?

Edited by BetaLeaf

 

 

Link to comment
Share on other sites

BinaryToString is leaving the null character on the end of the path, you'll have to strip it away.
 

$sBinaryVideoPath = RegRead("HKEY_CURRENT_USER\SOFTWARE\NVIDIA Corporation\Global\ShadowPlay\NVSPCAPS", "DefaultPathW")
$sVideoPath = BinaryToString($sBinaryVideoPath, 2)
$sVideoPath = StringStripWS($sVideoPath, 2)
$sVideoPath &= "\TEST"
InputBox("","",$sVideoPath)

 

Link to comment
Share on other sites

  • Developers

The last character is the string is Hex 00, so you need to strip that:

$sBinaryVideoPath = Binary("0x43003A005C00550073006500720073005C0062006500740061006C005C004F006E006500440072006900760065005C0044006F00630075006D0065006E00740073005C0056006900640065006F0073000000")
$sVideoPath = BinaryToString($sBinaryVideoPath, 2)
$sVideoPath = StringTrimRight($sVideoPath, 1)
$sVideoPath &= "\TEST"
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sVideoPath = ' & $sVideoPath & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...