欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python hook監(jiān)聽事件詳解

 更新時間:2022年03月23日 09:56:07   作者:vpoet  
這篇文章主要為大家詳細(xì)介紹了python hook監(jiān)聽事件的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了python hook監(jiān)聽事件的具體代碼,供大家參考,具體內(nèi)容如下

# -*- coding: utf-8 -*- # 
# by oldj http://oldj.net/ #
import pythoncom 
import pyHook  
def onMouseEvent(event): 
  # 監(jiān)聽鼠標(biāo)事件   
  print "MessageName:",event.MessageName   
  print "Message:", event.Message   
  print "Time:", event.Time   
  print "Window:", event.Window   
  print "WindowName:", event.WindowName   
  print "Position:", event.Position   
  print "Wheel:", event.Wheel   
  print "Injected:", event.Injected      
  print"---"
 
  # 返回 True 以便將事件傳給其它處理程序   
  # 注意,這兒如果返回 False ,則鼠標(biāo)事件將被全部攔截   
  # 也就是說你的鼠標(biāo)看起來會僵在那兒,似乎失去響應(yīng)了   
  return True
 
def onKeyboardEvent(event):
 # 監(jiān)聽鍵盤事件   
  print "MessageName:", event.MessageName   
  print "Message:", event.Message   
  print "Time:", event.Time   
  print "Window:", event.Window   
  print "WindowName:", event.WindowName   
  print "Ascii:", event.Ascii, chr(event.Ascii)   
  print "Key:", event.Key   
  print "KeyID:", event.KeyID   
  print "ScanCode:", event.ScanCode   
  print "Extended:", event.Extended   
  print "Injected:", event.Injected   
  print "Alt", event.Alt   
  print "Transition", event.Transition   
  print "---"   
  # 同鼠標(biāo)事件監(jiān)聽函數(shù)的返回值   
  return True 
 
def main():   
  # 創(chuàng)建一個“鉤子”管理對象   
  hm = pyHook.HookManager()   
  # 監(jiān)聽所有鍵盤事件   
  hm.KeyDown = onKeyboardEvent   
  # 設(shè)置鍵盤“鉤子”   
  hm.HookKeyboard()   
  # 監(jiān)聽所有鼠標(biāo)事件   
  hm.MouseAll = onMouseEvent   
  # 設(shè)置鼠標(biāo)“鉤子”   
  hm.HookMouse()   
  # 進(jìn)入循環(huán),如不手動關(guān)閉,程序?qū)⒁恢碧幱诒O(jiān)聽狀態(tài)   
  pythoncom.PumpMessages() 
 
if __name__ == "__main__":   
  main()

運(yùn)行截圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論