How can i fix my problem? I want to check if there is a specific word in a Textfile line and then run some code. Can someone please help me? Thanks alot.
if key == Key.left:
mouse.move(901, 350, absolute=True, duration=0.02)
time.sleep(0.0001)
mouse.click("left")
time.sleep(0.0001)
f = open('Get Position.txt', 'a+')
f.write('LEFT \n')
if key == Key.enter:
file = open('Get Position.txt', 'r')
file.close()
with open('Get Position.txt') as file:
contents = file.read()
search_word = linecache.getline('Get Position.txt', 1)
if search_word in contents == 'LEFT \n':
print('LEFT WAS PRESSED')
mouse.move(901, 350, absolute=True, duration=0.02)
time.sleep(0.0001)
mouse.click("left")