S
S
Snoppybot2021-12-20 13:54:58
Python
Snoppybot, 2021-12-20 13:54:58

How to write the interval between 1 and 35 in If?

My code:

import pyscreenshot as ImageGrab
import time
import cv2
import pyautogui
import keyboard
import pytesseract
from ahk import AHK

def aboba():
    pyautogui.press('enter'), pyautogui.typewrite('/homefast'), pyautogui.press('enter')
    print("хом")
    time.sleep(2)


time.sleep(1)
while True:
    if __name__ == "__main__":
        im = ImageGrab.grab(bbox=(190, 1011, 209, 1023))  # X1,Y1,X2,Y2
        im.save('screen.png')
        img = cv2.imread('screen.png')
        img = cv2.resize(img, None, fx=9, fy=9)
        HP = pytesseract.image_to_string(img, config='outputbase digits')
        print(HP)
        if HP in range(1 - 35):
            aboba()

The bottom line is that when HP was = From 1 to 35, it would perform an action (If I write If HP > 0 and HP < 36, then it performs an action at 100 HP, When I use range(), it does not see at all if)
I'm a beginner, if anything, don't kick me, please...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Bogdan Nikolenko, 2021-12-20
@Snoppybot

if int(HP) in range(1,35)
aboba()

V
Vasily Bannikov, 2021-12-20
@vabka

It seems to me that the answer from this question is quite applicable to this one: https://qna.habr.com/q/1085468

hpInt = int(HP)
if hpInt >= 1 and hpInt <= 35:
  aboba()

V
Vindicar, 2021-12-20
@Vindicar

if 1 <= int(HP) <= 35:
    aboba()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question