import win32api,time
while True:
a = win32api.GetKeyState(0x57)
if a <0:
print("w")
a = win32api.GetKeyState(0x53)
elif a <0:
print('s')
time.sleep(0.1)
im super new to python the line elif a<0
gives me the error ```expected expression`` what do i do to make it work? thanks
CodePudding user response:
You need a correct indentation in your code when you use if
and while
structures, because that will determine the instructions that execute in a certain moment:
import win32api, time
while True:
a = win32api.GetKeyState(0x57)
if a < 0:
print("w")
a = win32api.GetKeyState(0x53)
if a < 0:
print('s')
time.sleep(0.1)