我的背景: 我用python做了很多编程,我会说我不错。我熟悉大多数模块,OOP编程和东西。您可以查看我的pastebin配置文件,了解我的实际情况:www.pastebin.com/u/GameNationRDF /
守则:
from tkinter import *
import time
master = Tk()
def uiPrint():
info()
print ("")
print (click)
blankLine()
def info():
print ("Double click purchases need 750 clicks!")
info()
click = 0
mult = 1
dcp1 = 0
def blankLine():
for i in range(20):
print ("")
def purchaseDoubleClicksCommand():
global click
global mult
if click < 750:
print ("Not enough clicks!")
blankLine()
elif click >= 750:
mult = mult*2
click = click - 750
print ("Double Clicks Purchased!")
blankLine()
def buttonCommand():
global click
global mult
click += 1*(mult)
uiPrint()
if click == 100:
print ('''Achievement Unlocked: Junior Clicker!
BONUS 100!''')
click += 100
elif click == 400:
print ('''Achievement Unlocked: Little Ninja Clicks!
BONUS 200!''')
click += 300
elif click == 900:
print ('''Achievement Unlocked: Legit Ninja!
DOUBLE CLICKS!''')
mult = mult * 2
elif click == 1500:
print ('''Achievement Unlocked: Click Ninja Master!
QUAD CLICKS!''')
mult = mult * 4
elif click == 3000:
print ('''Achievement Unlocked: Jackie Chan Style!
8 TIMES THE CLICKS!''')
mainClickButton = Button(master, text="Click!", command=buttonCommand)
mainClickButton.pack()
purchaseDoubleClickButton = Button(master, text="Purchase Double Clicks", command = purchaseDoubleClicksCommand)
purchaseDoubleClickButton.pack()
master.title("Clicker! v0.0.6")
master.geometry("%sx%s+%s+%s" % (200,70,512,512))
mainloop()
我需要一种能够添加自动点击器的方法,该点击器会在给定时间内添加一定数量的Cookie。我希望它可以通过按钮购买。我不能让它工作:(
有任何帮助吗?谢谢:))
答案 0 :(得分:2)
PyUserInput project看起来很有前途和直截了当:
from pymouse import PyMouse
m = PyMouse()
x_dim, y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2, 1)
为什么你import *
顺便说一下?导入比所需更多的依赖项是不好的做法。
如果我是你,我会移动以下代码部分:
master = ()
info()
click = 0
mult = 1
dcp1 = 0
驻留在这一行之上:
mainlickButton = Button(master, text="Click!", command=buttoncommand)
添加声明和功能更加清晰。它现在没有产生GINORMOUS差异,但是当你的文件变大并且你有很多代码时它会更容易阅读。