Python's method of using a shear plate


This piece of code can use the clipboard, automatic copy and paste functions. (Windows)

import sys
import os.path
import win32clipboard as w
import win32con
import win32api
def getText():# Reading board
 w.OpenClipboard()
 d = w.GetClipboardData(win32con.CF_TEXT)
 w.CloseClipboard()
 return d
def setText(aString):# Write clipboard
 w.OpenClipboard()
 w.EmptyClipboard()
 w.SetClipboardData(win32con.CF_TEXT, aString)
 w.CloseClipboard()
if __name__=='__main__':
 a=" hello "
 setText(a)# Write "Hello" to the clipboard
 # Automatically paste the contents of the clipboard
 win32api.keybd_event(17,0,0,0) #ctrl The key code is 17
 win32api.keybd_event(86,0,0,0)#v The key code is 86
 win32api.keybd_event(86,0,win32con.KEYEVENTF_KEYUP,0) # Release the button
 win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
 win32api.keybd_event(13,0,0,0)#Enter The key code is 13
 win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)