INI to path error

  • Yea it is a mess. I can not get the $Var to work.

    Code
    MsgBox(4096, "Result", $var3&$Var1&$var2)
    ShellExecuteWait ("$var3&$Var1&$var2")

    MsgBox works

    The MsgBox shows all the $Var but ShellExecute shows no Varaiable available

    How do we set paths with Variables?

    Spoiler anzeigen

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    #Include <String.au3>
    #include <File.au3>
    AutoItSetOption("ExpandEnvStrings",1)
    FileChangeDir(@ScriptDir)
    _cmd1()
    Func _cmd1()
    $Var2 = IniRead("C:\0TIH\settings.ini", "gameexes", "game1", "There is a problem with the .ini file")
    MsgBox(4096, "Result", $var2)
    $Var3 = IniRead("C:\0TIH\settings.ini", "params", "root", "There is a problem with the .ini file")
    MsgBox(4096, "Result", $var3)

    Local $Var1 = IniRead("C:\0TIH\settings.ini", "WorkDir", "Path1", "There is a problem with the .ini file")
    MsgBox(4096, "Result", $var1)
    Global $TestPath = _PathMake("c:", "\0TIH\TIH1", "TIH1", "exe")
    MsgBox(0, "demo _PathMake", $TestPath)
    MsgBox(4096, "Result", $var3&$Var1&$var2)
    FileChangeDir ( "$var1" )
    FileChangeDir ( "$path1" )
    MsgBox(4096, "Result", "$path1")
    ShellExecuteWait ( " $TestPath" )
    ShellExecuteWait ( " $var3&$Var1&$var2" )
    EndFunc ;==> _cmd1

    Settings.ini

    Spoiler anzeigen


    [WorkDir]
    C:\0TIH
    C:\0TIH\1a\
    C:\0TIH\2a\
    C:\0TIH\3a\
    [command]


    [params]
    C:\0TIH

    [text]
    C:\0TIH\1a\1a.exe
    C:\0TIH\2a\2a.exe
    C:\0TIH\3a\3a.exe

    [Games]
    LComplete=1


    Now the lesson here is I am trying to find out how to pass a variable to a command FileChangeDir ("$Var1") or in this

    Spoiler anzeigen

    #Shift-Alt-q
    HotKeySet("+!q", "Close")
    AutoItSetOption("ExpandEnvStrings",1)
    #call startup
    Start()
    Func Start()
    Opt("TrayIconHide",1)

    $regVal = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName)
    if $regVal = 1 OR -1 OR -2 Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptDir)
    EndIf
    Loop()
    EndFunc

    Func Loop()
    Do
    $x = WinExists ( "0aTest" )
    Until $x = 1
    WinSetState ( "0aTest", "", @SW_HIDE)
    Password()
    EndFunc

    Func Password()
    $Var1 = IniRead("@WindowsDir\settings.ini", "WorkDir", "Path1", "There is a problem with the .ini file")
    MsgBox(4096, "Result", $var1)
    $user = InputBox ( "Trouble In Heaven", "Classified. Please enter authentication credentials.","$Var1", "*" )
    If $user = "" Then
    MsgBox( 1, "ERROR", "authentication INVALID NOW EXITING!", 30)
    Exit
    If $user = "$Var1" Then
    MsgBox( 1, "Accepted", "authentication credentials accepted!", 30)
    FileChangeDir ( "C:\0aTest\1a" )
    $file = "C:\0aTest\1a\1a.exe"
    ShellExecuteWait($file)
    EndIf
    Else
    WinClose ( "0aTest" )
    MsgBox( 1, "Rejected!", "authentication INVALID NOW EXITING!", 5)
    keepOpen()
    EndIf
    EndFunc

    Func keepOpen()
    Do
    $x = WinExists ( "0aTest" )
    Until $x = 0
    Loop()
    EndFunc

    Func Close()
    Exit 0
    EndFunc

    In this I am trying to pass $var1 to If $user = "$Var1" Then but unless I type in the username it will not work.

    Can some one please explain to me how this works?

    Many Thanks

  • I'm not sure if I understood you correctly, but have you tried to use the variables in the parameter without double quotes?

    [autoit]

    ShellExecuteWait ("$var3&$Var1&$var2")

    [/autoit]


    Why you decided to use quote marks for ShellExecuteWait but not for MsgBox is a mystery to me :D.
    If you put any expression in double quotes then AutoIt will interprete it as a normal string. So the actual value that's passed to the ShellExecute function is "$var3&$Var1&$var2" in text form. The content of the variables is then irrelevant.
    If you use the variable without any quotes then AutoIt will interprete the content if the variable. This is true for any operation that can be performed with variables, whether you want to multiply two variables or concatenate them or pass them as a parameter to a function, you do not use quote marks if you want those actions to be performed with the content rather than the name of the variable.

    By the way, you do know that there is an English board for AutoIt (autoitscript.com) where more people will actually understand you? ^^

  • Zitat

    Why you decided to use quote marks for ShellExecuteWait but not for MsgBox is a mystery to me :D.
    If you put any expression in double quotes then AutoIt will interprete it as a normal string


    Thank you for replying. The reason is simple. I did not know.

    Now however,Local $Var1 = IniRead("C:\0TIH\settings.ini", "WorkDir", "Path1", "There is a problem with the .ini file")
    MsgBox(4096, "Result", $var1) displays the correct result. so I would think that

    FileChangeDir ("$var1")

    MsgBox(4096, "Result", $var1) displays $var1 and not the path

    FileChangeDir ('$var1')

    MsgBox(4096, "Result", $var1) displays $var1 not the path

    Reason I am attempting to find a answer here is I make games. Well try to. and the english forum does not allow any posts to do with games at all. I have little experence with Autoit but have read almost every post in the English, Russian and German forums in a attempt to learn as much as I can as fast as I can. I did post here using the Google translator as was told NOT to use it but post in English.

    Now can I please find out how to get a var to work ?

  • I guess I'll quote myself now...

    Zitat von name22

    I'm not sure if I understood you correctly, but have you tried to use the variables in the parameter without double quotes?

    Single and double quotes have the same meaning in AutoIt so it won't make a difference which one you use. You need to use the variable without any quotes.
    Like that:

    [autoit]

    ShellExecuteWait ($var3&$Var1&$var2)

    [/autoit]


    If you use quotes, then AutoIt will assume that you want to use the text "$var3 etc." as a Parameter. If it didn't do that then you wouldn't be able to use the '$' sign in a String in AutoIt.

    Zitat

    I have little experence with Autoit but have read almost every post in the English, Russian and German forums in a attempt to learn as much as I can as fast as I can. I did post here using the Google translator as was told NOT to use it but post in English.


    Admirable :). And I agree with whoever told you that you should NOT use Google Translator. Their Translator is known for messing up any text so badly that either A) no one will understand you or B) the text has the opposite meaning of whatever you want to say :D.

    Zitat

    and the english forum does not allow any posts to do with games at all


    Are you sure :huh: . That seems strange to me. We also forbid any posts related to manipulating games or cheating/botting, but some of us actually make their own games (like me) and normally get very positive feedback. I don't see any reason to not tolerate posts related to games...