-1

i created this small programm in python 3.9 whose goal is, to play "piano tiles" automatically. Im facing some issues with the if clause in the "setValues" function. As you can see in the code, im trying to find out if the user wants to use default x values, or wants to input some. But even though i enter yes (default values in a text file, it is running the first if clause and not the elif part. I have absoulutly no idea why this is happening. Can anyone help me?

console after entering "y"

import pyautogui
import win32api
import win32con
import keyboard



def setValues():
    valueList = []
    userInput = input("do you want to use default values? (y/n): ")
    if userInput == "n" or "no" or "na":
        print("no")
        print("\n")
        while True:
            try:
                valueList.clear()
                valueList.append(int(input("enter the first x-value: ")))
                valueList.append(int(input("enter the second x-value: ")))
                valueList.append(int(input("enter the third x-value: ")))
                valueList.append((input("enter the fourth x-value: ")))
                return valueList
                break
            except:
                print("\nplease enter a number!\n")
                continue

    elif userInput == "y" or "yes" or "yeah":
        print("yes")
        with open("values.txt") as file:
            for line in file.readline():
                int(line)
                valueList.append(line)
        return valueList

    else:
        print("sorry, this answer is not accepted!")
        setValues()


def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)

valueList = setValues()

while True:
    if keyboard.is_pressed('s'):
        while keyboard.is_pressed('q') == False:
            try:

                if pyautogui.pixel(valueList[0], 500)[0] == 0:
                    click(valueList[0], 520)
                if pyautogui.pixel(valueList[2], 500)[0] == 0:
                    click(valueList[2], 520)
                if pyautogui.pixel(valueList[3], 500)[0] == 0:
                    click(valueList[3], 520)
                if pyautogui.pixel(valueList[4], 500)[0] == 0:
                    click(valueList[4], 520)
            except:
                continue
Uzzlius
  • 13
  • 3

1 Answers1

0

Your if statement is incorrect, try:

elif userInput == "y" or userinput == "yes" or userniput == "yeah":
cwittah
  • 349
  • 1
  • 3
  • 17