简体   繁体   中英

automatic press key in Python

im currently trying to make a auto-clicker and then a auto-button presser.

this is my code until now.

new=2;
url="www.google.com";

webbrowser.open(url,new=new);

time.sleep(25)


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(700,300)

time.sleep(3)

And after time.sleep(3) I want the spacebar to be pressed automatic (with 3sec sleep in between) 100 times. I have tried sendkeys, but cant find any download place.

Sorry for bad english, hope someone can help.

这个问题这个 问题可能会对您有所帮助,您可能应该搜索这些内容并在发布之前检查是否已经存在类似的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM