I'm trying to make a program that will take a word from a .txt file and will press a keyboard key. I'm doing it so my Twitch chat can control my keyboard by a command. Below is the code without the key press (it doesn't work).
with open('C:\Users\laith\AppData\Roaming\HexChat\logs\Twitch\#liongenz9629.log') as file:
contents = file.read()
search_word = input("test2")
if search_word in contents:
print ('word found')
else:
print ('word not found')
I also can't figure out how to press a key. I tried including the following code:
Send {F down}{Fup}
Send {F down}{Fup}
to make this:
with open('C:\Users\laith\AppData\Roaming\HexChat\logs\Twitch\#liongenz9629.log') as file:
contents = file.read()
search_word = input("test2")
if search_word in contents:
Send {F down}{Fup}
Send {F down}{Fup}
else:
print ('word not found')
But what I would like to know, is why it didn't work. I researched it extensively and could not find a fix, so alas here I am...
I am using Python 2.7.18 64-Bit
PC: Windows 10 Home Version 1903 Build 18362.959