Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Connector with Python

Shulou Source: shulou.com Published: 2022-06-01 10:51:08 10月17日 Update

This article mainly introduces how to achieve the Python connector, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Ah, for this reason, I have specially prepared two programs, one for testing and the other for the main program. Come and see

# improved version import pyautogui as pagfrom time import sleep,timepag.PAUSE = 0def mouse (): B = input ('how many clicks do you need?') B = int (b) c = input ('do you need a left or right button when you click? \ nPlease enter 0 on the left button, and right-enter 1') c = int (c) print ('Please note: you need to move the mouse to the point where you need to connect within 8 seconds, then don't move, wait for the quick connection to begin.') Sleep (8) print ('start clicking!') XMagi y = pag.position () d = 'left' if c: d =' right' e = time () for i in range (0rem b): pag.click (XMagne yButton = d) f = time ()-e input ('finished. It took% f seconds.' % f) def key (): print ('Please select the keys you need from the supported keys below.') For i in pag.KEYBOARD_KEYS: print (ringing% s'% iRegent endgame') b = input ('\ nPlease enter the characters you need to type quickly:') if b in pag.KEYBOARD_KEYS: C = input ('Please enter how many times you need to enter:') c = int (c) print ('Please note that you need to switch to the window you need to enter within 8 seconds.') Sleep (8) print ('get to work!') E = time () for i in range (0rem c): pag.press (b) f = time ()-e input ('complete. It took% f seconds.' % f) else: input ('the character you entered is not a supported character, please modify it.') Try: a = input ('enter the service you need (number):\ N1: quick connection point\ N2: quick input\ n >') a = int (a) if a = = 1: mouse () elif a = = 2: key () else: input ('Sorry, I can't find the service you need. \ n') except Exception as e: print ('error;\ nbadgery e)

Test program:

Import pygamefrom pygame.locals import * from pygame.color import THECOLORSpygame.init () canvas = pygame.display.set_mode ((600600)) canvas.fill ((255255255)) pygame.display.set_caption ('TEST') # mouse clicks mouBut = number of times the space bar is pressed keyDow = 0def handle (): global mouBut KeyDow for event in pygame.event.get (): if event.type = = QUIT: pygame.quit () exit () # when the mouse is pressed if event.type = = MOUSEBUTTONDOWN: XCoI y = event.pos # and if 200in the black rectangle

Tags: Program input test mouse article character support main program place fast number of times rectangle space space bar keyboard service sorry this not good two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology NVidia Xiaomi Linux