Python按键脚本
from pynput.mouse import Button, Controller
import time
mouse = Controller()
print(mouse.position)
mouse.position = (100, 500)
for index in range(0, 30):
mouse.move(index, -index)
print(mouse.position)
time.sleep(0.01)
for index in range(0, 30):
mouse.move(-index, index)
print(mouse.position)
time.sleep(0.01)
mouse.press(Button.right)
time.sleep(0.01)
mouse.release(Button.right)
mouse.click(Button.left, 1)
mouse.scroll(0, 500)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
from pynput.keyboard import Key, Controller, KeyCode
keyboard = Controller()
keyboard.press('a')
keyboard.release('a')
keyboard.press(Key.shift)
keyboard.press('b')
keyboard.release('b')
keyboard.press('c')
keyboard.release('c')
keyboard.release(Key.esc)
with keyboard.pressed(Key.shift):
keyboard.press('d')
keyboard.release('d')
keyboard.press('e')
keyboard.release('e')
keyboard.type(' python')
keyboard.touch(KeyCode.from_vk(56), True)
keyboard.touch('a', True)
keyboard.touch('a', False)
keyboard.touch(Key.shift, False)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
from pynput.keyboard import Key, Controller
import threading
from pynput import mouse
import tkinter
from sys import exit
keyboard = Controller()
class MouseActionListener(threading.Thread):
def __init__(self):
super().__init__()
def run(self):
def on_click(x, y, button, pressed):
print(button)
if str(button) == 'Button.left':
with keyboard.pressed(Key.ctrl):
keyboard.press(Key.alt)
keyboard.press('.')
keyboard.release(Key.alt)
keyboard.release('.')
elif str(button) == 'Button.middle':
with keyboard.pressed(Key.ctrl):
keyboard.press(Key.alt)
keyboard.press(',')
keyboard.release(Key.alt)
keyboard.release(',')
with mouse.Listener(on_click=on_click) as listener:
listener.join()
@classmethod
def stop(cls):
exit()
def button_onClick(action):
m1 = MouseActionListener()
if action == 'listener':
if startListenerBtn['text'] == '开启':
m1.daemon = True
m1.start()
startListenerBtn['text'] = '开启中...再次点击停止进程'
elif startListenerBtn['text'] == '开启中...再次点击停止进程':
m1.stop()
startListenerBtn['text'] = '开启'
if __name__ == '__main__':
root = tkinter.Tk()
root.title('翻页神器')
root.geometry('250x100')
startListenerBtn = tkinter.Button(root, text="开启", command=lambda: button_onClick('listener'))
startListenerBtn.place(x=35, y=10, width=180, height=80)
root.mainloop()

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
#include<stdio.h>
main() {
int a=010,b=10;
printf("%d,%d\n",a++,--b);
}