我想创建一个非常简单的自动点击器,它将使用鼠标的位置,并在该位置单击,只要“ active”为true且以“ input”的速度(每秒点击数)
我已经看到了这段代码,但是它不符合我的需求
import win32api, win32con
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
click(10,10)
Run Code Online (Sandbox Code Playgroud)
我希望代码看起来像这样,
import library
input = 5 ## in clicks per second
if (some key) is held:
active = True
if (some key) is released:
active = False
while active:
*gets position of mouse*
*clicks at that position at input's speed (5)
Run Code Online (Sandbox Code Playgroud)
如果可以单击屏幕的正中央,这也很好。
我正在创建一个黑色杰克启发游戏,我使用以下代码生成甲板和手:
suits = 'SCHD'
values = '23456789TJQKA'
deck = tuple(''.join(card) for card in itertools.product(values, suits))
dealershand = random.sample(deck, 1)
yourhand = random.sample(deck, 2)
Run Code Online (Sandbox Code Playgroud)
这样做的问题是,在'dealerhand'和'yourhand'中拉出同一张卡的可能性很小我想检查该卡是否已经存在,如果存在,则生成另一张卡.像这样的东西:
while yourhand is in dealershand:
yourhand=random.sample(deck,2)
Run Code Online (Sandbox Code Playgroud)