#coding:utf-8 import os import time import win32api import win32con import win32clipboard as w import subprocess striepath="c:\\PROGRA~1\\INTERN~1\\iexplore.exe" def getText(): w.OpenClipboard() d = w.GetClipboardData(win32con.CF_TEXT) w.CloseClipboard() return d def setText(aString): w.OpenClipboard() w.EmptyClipboard() w.SetClipboardData(win32con.CF_TEXT, aString) w.CloseClipboard() child = subprocess.Popen(striepath) time.sleep(10) #发送F6 win32api.keybd_event(117,0,0,0) win32api.keybd_event(117,0,win32con.KEYEVENTF_KEYUP,0) time.sleep(1) #发送ctrl win32api.keybd_event(17,0,0,0) win32api.keybd_event(67,0,0,0) win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0) time.sleep(1) #发送c win32api.keybd_event(67,0,win32con.KEYEVENTF_KEYUP,0) time.sleep(1) print(getText())
代码抄自:http://blog.log4d.com/2010/10/python-clipboard/