Pycharm-Python3.7+pynput-实现clientAutoLogin

Pycharm-Python3.7+pynput-实现clientAutoLogin

  • Ⅰ-Prepare
  • Ⅱ-Coding

Ⅰ-Prepare

Install pynput pags:
①Pycharm Menu->file->Settings->Project Interpreter;
②click ‘+’ button into the ‘Availbale Packages’;
③search ‘pynput’ and Install it;
④close ‘Settings’ page ,finish installation;

Ⅱ-Coding

import time
from pynput import keyboard, mouse
mouse1 = mouse.Controller()
Button = mouse.Button
key = keyboard.Controller()
Key = keyboard.Key
key.press(Key.cmd)
key.press("r")
key.release(Key.cmd)
key.release("r")
time.sleep(0.5)
key.press(Key.delete)
key.release(Key.delete)
url1 = "C:\\Users\\lenovo\\Desktop\\PC.lnk"
for urlE in url1:
    print(urlE, end='')
    key.press(urlE)
    key.release(urlE)
print('\n')
key.press("\r")
key.release("\r")
key.press("\r")
key.release("\r")
targetMouseX = 920
targetMouseY = 370
mouse1.position = (0, 0)
time.sleep(3)
mouse1.move(targetMouseX, targetMouseY)
print(mouse1.position)
mouse1.click(Button.left)
name = 'iamuname'
for nameE in name:
    key.press(nameE)
    key.release(nameE)
time.sleep(1)
key.press('\t')
key.release('\t')
passwd = 'iampasswd'
for passwdE in passwd:
    key.press(passwdE)
    key.release(passwdE)
time.sleep(1)
key.press('\t')
key.release('\t')
time.sleep(1)
key.press('\r')
key.release('\r')

你可能感兴趣的:(Python)