Problem

  • Ich habe folgenden Code

    [autoit]


    Opt("SendKeyDelay", 0)
    Opt("SendKeyDownDelay", 0)

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    $readcarlock = iniread ($ini,"Settings","/carlock","")
    $readexit = iniread ($ini,"Settings","/exit","")
    $readenter = iniread ($ini,"Settings","/enter","")
    $readrespray = iniread ($ini,"Settings","/respraycar","")
    $readfix = iniread ($ini,"Settings","/fixcar","")
    $call911 = iniread ($ini,"Settings","/callpolice","")
    $readkill = iniread ($ini,"Settings","/kill","")
    $readfill = iniread ($ini,"Settings","/fill","")
    $readfuel = iniread ($ini,"Settings","/get fuel","")
    Hotkeyset ($readcarlock,"carlock")
    Hotkeyset ($readexit,"exit_")
    Hotkeyset ($readenter,"enter_")
    Hotkeyset ($readrespray,"respraycar_")
    Hotkeyset ($readfix,"fixcar_")
    Hotkeyset ($call911,"police_")
    hotkeyset ($readkill,"kill_")
    Hotkeyset ($readfill,"fill_")
    Hotkeyset ($readfuel,"getfuel_")

    [/autoit][autoit][/autoit][autoit]

    func carlock ()
    send ("{t}")
    sleep (500)
    send ("/carlock")
    send ("{enter}")
    EndFunc

    [/autoit]

    Mit den Funktionen gehts nach unten noch weiter, aber ich lass ma dieses carlock beispiel stehen.

    So, wenn ich meinen Hotkey jetzt definiert habe und drücke tut er einfach nicht. Kann mir jmd sagen worans liegt ?

    MFG

    Einmal editiert, zuletzt von Hellwave (11. Februar 2009 um 21:54)

  • Hast du dir mal angeguckt welchen wert iniread ($ini,"Settings","/carlock","") ausgibt?
    Funktioniert der code wenn du direkt den $readcarlock den wert zuweist?
    Einfach mal verschiedene Sachen ausprobieren....

    edit: war einer schneller ;)

  • Spoiler anzeigen
    [autoit]


    Opt("SendKeyDelay", 0)
    Opt("SendKeyDownDelay", 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $readcarlock = iniread ($ini,"Settings","/carlock","")
    $readexit = iniread ($ini,"Settings","/exit","")
    $readenter = iniread ($ini,"Settings","/enter","")
    $readrespray = iniread ($ini,"Settings","/respraycar","")
    $readfix = iniread ($ini,"Settings","/fixcar","")
    $call911 = iniread ($ini,"Settings","/callpolice","")
    $readkill = iniread ($ini,"Settings","/kill","")
    $readfill = iniread ($ini,"Settings","/fill","")
    $readfuel = iniread ($ini,"Settings","/get fuel","")
    Hotkeyset ($readcarlock,"carlock")
    Hotkeyset ($readexit,"exit_")
    Hotkeyset ($readenter,"enter_")
    Hotkeyset ($readrespray,"respraycar_")
    Hotkeyset ($readfix,"fixcar_")
    Hotkeyset ($call911,"police_")
    hotkeyset ($readkill,"kill_")
    Hotkeyset ($readfill,"fill_")
    Hotkeyset ($readfuel,"getfuel_")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    sleep(100)
    WEnd
    func carlock ()
    send ("{t}")
    sleep (500)
    send ("/carlock")
    send ("{enter}")
    EndFunc

    [/autoit]


    Die Schleife verhindert das Beenden des Skriptes.

  • Ne While-Schleife haste ja vermutlich, das müsstest du ja merken^^.
    Check einfach nochmal alles durch, weil so funktioniert es ja:

    [autoit]

    Opt("SendKeyDelay", 0)
    Opt("SendKeyDownDelay", 0)

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    $readcarlock = "{F1}"
    Hotkeyset ($readcarlock,"carlock")

    [/autoit][autoit][/autoit][autoit]

    While True
    Sleep(100)
    WEnd

    [/autoit][autoit][/autoit][autoit]

    func carlock ()
    send ("{t}")
    sleep (500)
    send ("/carlock")
    send ("{enter}")
    EndFunc

    [/autoit]
  • Habs hingekriegt, trotzdem thx :) Der fehler war simpel :

    Hatte die Hotkeyabfrage ausversehn ins IF einer funktion gesetzt :)

    Einmal editiert, zuletzt von Hellwave (11. Februar 2009 um 21:33)

    • Offizieller Beitrag

    Probier mal das :

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $ini = @ScriptDir & "\config.ini"
    Opt("SendKeyDelay", 1)
    Opt("SendKeyDownDelay", 1)

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("GTAdvanced", 234, 186, 192, 127)
    $Group1 = GUICtrlCreateGroup("GTAdvanced", 8, 8, 217, 169)
    $Label1 = GUICtrlCreateLabel("Verfügbare Befehle :", 16, 32, 101, 17)
    $ComboMain = GUICtrlCreateCombo("", 16, 56, 145, 25)
    GUICtrlSetData(-1, "/carlock|/exit|/enter|/respraycar|/fixcar|/call 911 Polizei|/kill|/fill|/get fuel")
    $Button1 = GUICtrlCreateButton("Hotkey setzen", 16, 88, 83, 25, 0)
    $Label2 = GUICtrlCreateLabel("Befehle hinzufügen :", 16, 120, 101, 17)
    $Input1 = GUICtrlCreateInput("", 16, 144, 121, 21)
    $Button2 = GUICtrlCreateButton("Hinzufügen", 144, 142, 75, 25, 0)
    $Label3 = GUICtrlCreateLabel("Status :", 110, 93, 40, 17)
    $Label4 = GUICtrlCreateLabel("", 160, 93, 60, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($Input1, $GUI_DISABLE)
    GUICtrlSetState($Button2, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button1
    If GUICtrlRead($ComboMain) = "/carlock" Then

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/carlock", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd
    ElseIf GUICtrlRead($ComboMain) = "/exit" Then

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/exit", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/enter" Then
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/enter", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/respraycar" Then

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/respraycar", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/fixcar" Then

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/fixcar", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/call 911 Polizei" Then
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/callpolice", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/kill" Then
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/kill", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/fill" Then

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/fill", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    GUICtrlSetData($Label4, "Erfolgreich !")
    If @error Then
    GUICtrlSetData($Label4, "Fehler !")
    EndIf
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($ComboMain) = "/get fuel" Then
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Hotkey setzen !", 173, 38, 234, 130)
    $Combo1 = GUICtrlCreateCombo("", 8, 8, 73, 25)
    GUICtrlSetData(-1, "Q|W|E|R|T|Z|U|I|O|P|Ü|A|S|D|F|G|H|J|K|L|L|Ö|Ä|Y|X|C|V|B|N|M|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9")
    $OK = GUICtrlCreateButton("OK", 88, 6, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE)
    Case $OK
    $readcombo1 = GUICtrlRead($Combo1)
    IniWrite($ini, "Settings", "/get fuel", "{" & $readcombo1 & "}")
    GUISetState(@SW_HIDE)
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    $readcarlock = IniRead($ini, "Settings", "/carlock", "")
    $readexit = IniRead($ini, "Settings", "/exit", "")
    $readenter = IniRead($ini, "Settings", "/enter", "")
    $readrespray = IniRead($ini, "Settings", "/respraycar", "")
    $readfix = IniRead($ini, "Settings", "/fixcar", "")
    $call911 = IniRead($ini, "Settings", "/callpolice", "")
    $readkill = IniRead($ini, "Settings", "/kill", "")
    $readfill = IniRead($ini, "Settings", "/fill", "")
    $readfuel = IniRead($ini, "Settings", "/get fuel", "")
    HotKeySet($readcarlock, "carlock")
    HotKeySet($readexit, "exit_")
    HotKeySet($readenter, "enter_")
    HotKeySet($readrespray, "respraycar_")
    HotKeySet($readfix, "fixcar_")
    HotKeySet($call911, "police_")
    HotKeySet($readkill, "kill_")
    HotKeySet($readfill, "fill_")
    HotKeySet($readfuel, "getfuel_")
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func carlock()
    Send("{t}")
    Sleep(500)
    Send("/carlock")
    Send("{enter}")
    EndFunc ;==>carlock

    [/autoit] [autoit][/autoit] [autoit]

    Func exit_()
    Send("{t}")
    Send("/exit")
    Send("{enter}")
    EndFunc ;==>exit_

    [/autoit] [autoit][/autoit] [autoit]

    Func enter_()
    Send("{t}")
    Send("/enter")
    Send("{enter}")
    EndFunc ;==>enter_

    [/autoit] [autoit][/autoit] [autoit]

    Func respraycar_()
    Send("{t}")
    Send("/respraycar")
    Send("{enter}")
    EndFunc ;==>respraycar_

    [/autoit] [autoit][/autoit] [autoit]

    Func fixcar_()
    Send("{t}")
    Send("/fixcar")
    Send("{enter}")
    EndFunc ;==>fixcar_

    [/autoit] [autoit][/autoit] [autoit]

    Func police_()
    Send("{t}")
    Send("/call 911")
    Sleep(500)
    Send("Polizei")
    Send("{enter}")
    EndFunc ;==>police_

    [/autoit] [autoit][/autoit] [autoit]

    Func kill_()
    Send("{t}")
    Send("/kill")
    Send("{enter}")
    EndFunc ;==>kill_

    [/autoit] [autoit][/autoit] [autoit]

    Func fill_()
    Send("{t}")
    Send("/fill")
    Send("{enter}")
    EndFunc ;==>fill_

    [/autoit] [autoit][/autoit] [autoit]

    Func getfuel_()
    Send("{t}")
    Send("/get fuel")
    Send("{enter}")
    EndFunc ;==>getfuel_

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]

    Du hast die Hotkeys falsch in die INI geschrieben .Das setzen der Hotkeys war auch an der falschen Stelle in deiner Schleife.

    • Offizieller Beitrag

    Nach deinem Edit der Post hattest du es gerade mal 1 Minute vor mir. Aber egal , Hauptsache es funzt. ;)