I have this code:
#python 2.7.15
import pyautogui
import time
import msvcrt
from threading import Thread
import win32api
import battle
import Tkinter
from Tkinter import *
#launcher pos x:868 y:975
#rocket pos x:829 y:936
def click():
left = win32api.GetKeyState(0x01)
while True:
click = win32api.GetKeyState(0x01)
if click != left:
left = click
#print(a)
if click < 0:
pyautogui.hotkey("ctrlleft")
time.sleep(1)
def rocket():
rocket = True
while rocket:
pyautogui.hotkey("2")
time.sleep(0.5)
pyautogui.hotkey("7")
time.sleep(20)
root = Tk()
root.geometry("300x200")
root.title("Bot options")
root = Tkinter.Button(root, text = "Click me", command = rocket)
root.pack()
root.mainloop()
"""key = msvcrt.getche()
if key == 'z':
click()
elif key == 'x':
if __name__ == '__main__':
Thread(target = click).start()
Thread(target = battle.battle).start()
Thread(target = rocket).start()"""
The problem is that when running and I click the Click me button inside the window that is created, the window stops responding. I have tried changing command = rocket to command = rocket() but no window pops up and function starts working