Das Problem ist dieses Programm verbraucht relativ viel Arbeitsspeicher, da es die ganze Zeit eine While - Schleife am laufen hat um zu erkennen ob eine Taste gedrückt ist und wielange sie gedrückt bleibt.
Daher wollte ich fragen ob ihr eine Möglichkeit kennt wie ich die Leistung, die das Programm verbraucht, erheblich verringern kann, das Ergebnis aber das gleiche bleibt.
Hier der Code:
Code: Alles auswählen
import win32api
import win32con, time, tkinter
import win32api, win32gui, win32con, os ,time
def middle(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN,x,y,0,0)
time.sleep(.02)
win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP,x,y,0,0)
time.sleep(.02)
def click(x,y):
win32api.SetCursorPos((x,y)) # 0.02 ist das Minimum
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
time.sleep(.02)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def get_coords():
x,y = win32api.GetCursorPos()
return x,y
def setc(x,y):
coords = x,y
win32api.SetCursorPos(coords)
time.sleep(.02)
main = tkinter.Tk()
main.title("Zar1's skillshothelper")
lbl1 = tkinter.Label(main, text = "type in on which keys you have your four spells in UPPER CASE!!! (eg: Q )")
lbl1.pack()
lb2 = tkinter.Label(main, text = "if you don't want that this program affect a key typ in a lower case letter.")
lb2.pack()
e = tkinter.Entry(main,width = 4,)
e.pack()
e1 = tkinter.Entry(main,width = 4)
e1.pack()
e2 = tkinter.Entry(main,width = 4)
e2.pack()
e3 = tkinter.Entry(main, width = 4)
e3.pack()
def userdata():
c = 0
d = 0
i0 = e.get()
i1 = e1.get()
i2 = e2.get()
i3 = e3.get()
while(1):
a = win32api.GetAsyncKeyState(ord(i0))
a1 = win32api.GetAsyncKeyState(ord(i1))
a2 = win32api.GetAsyncKeyState(ord(i2))
a3 = win32api.GetAsyncKeyState(ord(i3))
if a or a1 or a2 or a3 == 0:
d = d+1
if a or a1 or a2 or a3 != 0:
d = 0
if d == 1:
gc = get_coords()
gc0 = gc[0]
gc1 = gc[1]
click(gc0,gc1)
btest = tkinter.Button(main, text = "Start",
command = userdata, height=2, width= 8,
font = "Arial 11 bold")
btest.pack()
lb3 = tkinter.Label(main, text = "made by zar1")
lb3.pack()
lb4 = tkinter.Label(main, text = "youtube.com/zbrotherz")
lb4.pack()
main.mainloop()