'Why does my Python bot not work? (PyAutoGUI)

I coded a bot in Python that should automatically play Friday Night Funkin' (press the arrows when they are meant to be pressed) but for some reason it doesn't do anything. I took screenshots of the arrows when they are meant to be pressed and I made it so if python sees that the arrow is meant to be pressed (it sees the images/screenshots) it presses the corresponding key. I tried turning greyscale off but it didn't work. Is there any way to fix this or make it in a different way? I'm really new to Python and this is my first code so sorry if it's a stupid problem and question.

My FNF Version: https://poki.pl/g/friday-night-funkin

My images: https://imgur.com/a/n8LUibP

My code:

from pyautogui import *
import pyautogui
import time
import keyboard
import numpy as np
import random
import win32api, win32con

time.sleep(5)

while keyboard.is_pressed('q') == False:

if pyautogui.locateOnScreen('leftarrow.png', region=(1010, 50, 650, 200), grayscale=False, confidence=0.7) != None:
    pyautogui.keyDown('left')
    time.sleep(0.1)
    pyautogui.keyUp('left')

if pyautogui.locateOnScreen('rightarrow.png', region=(1010, 50, 650, 200), grayscale=False, confidence=0.7) != None:
    pyautogui.keyDown('right')
    time.sleep(0.1)
    pyautogui.keyUp('right')
    
if pyautogui.locateOnScreen('uparrow.png', region=(1010, 50, 650, 200), grayscale=False, confidence=0.7) != None:
    pyautogui.keyDown('up')
    time.sleep(0.1)
    pyautogui.keyUp('up')

if pyautogui.locateOnScreen('downarrow.png', region=(1010, 50, 650, 200), grayscale=False, confidence=0.7) != None:
    pyautogui.keyDown('down')
    time.sleep(0.1)
    pyautogui.keyUp('down')


Solution 1:[1]

maybe it is copy-paste lag, but there is no indention before "if"

use "not None" instead of "!= None"

use

if __name__ == "__main__": 

your script as it now can be run only as python file, through console command or import.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Evgene