I'm making a macro, but I don't

Asked 2 years ago, Updated 2 years ago, 102 views

I'm totally a novice. I tried to make it quickly with a jupyter notebook, but it doesn't work.

When coordinate 1 turns white, press coordinate 2 button

import keyboard

import click

import time

import pyautogui as pag

from PIL import ImageGrab

from tkinter import *

win = Tk()

win.title("auto")

win.geometry("550x250")

win.option_add ("*font", "Gothic 20")

lab1 = Label(win)

lab1.config (text = "End Point")

lab1.grid(column = 0, row = 0, padx=20, pady=20)

lab2 = Label(win)

lab2.config (text = "Next Button")

lab2.grid(column = 0, row = 10, padx=20, pady=20)

ent1 = Entry(win)

ent1.grid(column = 1, row = 0, padx=20, pady=20)

ent1.insert(0, "1032, 736")

ent1.bind("<Button-1>", clear1)

ent2= Entry(win)

ent2.insert(0, "990, 704")

ent2.bind("<Button-1>", clear2)

ent2.grid(column = 1, row = 10, padx=20, pady=20)

ok_rgb = (255, 255, 255)

time_pos = (ent1.get())

next_btn = (ent2.get())

def start():

  while True:

        screen = ImageGrab.grab()

        rgb = screen.getpixel(time_pos)

        time.sleep(2)

        if rgb == ok_rgb:

            time.sleep(5)

            pag.click(next_btn)

            break

def end():

 **I want to end start.**

btn1 = Button(win)

btn1.config (text="start")

btn1.grid(column = 0, row = 20, padx=20, pady=20)

btn1.config(command = start)


btn2 = Button(win)

btn2.config (text="end")

btn2.grid(column = 1, row = 20, padx=20, pady=20)

btn2.config(command = end)

win.mainloop()

It's my first time, so I'm not sure if I can post it like

python jupyter-notebook

2022-09-20 17:55

1 Answers

"I want to end the start."

Is this your goal? Just set one global variable

As soon as you enter the start function, make it true.

whileTrue: Instead, while [variable name]

I think you can use the variable False in the end function.


2022-09-20 17:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.