問題描述
有沒有辦法檢測 Windows 上的模擬鍵盤/鼠標輸入.例如,用戶在他的鍵盤上輸入一些東西,而不是 sendKeys/PostMessage/屏幕鍵盤.有沒有辦法區分這兩者?
Is there a way to detect simulated keyboard/mouse input on Windows. For example, a user types something on his keyboard vs sendKeys/PostMessage/On-screen keyboard. Is there a way that I can distinguish between the two?
也許一個例子會有所幫助.我正在制作游戲并想區分真實輸入與 WinAPI 合成鍵盤/鼠標消息.
Perhaps an example would help. I am making a game and want to distinguish between real input vs WinAPI synthesizing keyboard/mouse messages.
推薦答案
我可能錯了,但屏幕鍵盤(和其他模擬用戶輸入的應用程序)很可能使用 SendInput API:
I might be wrong, but the on-screen keyboard (and other applications that simulate user input) most probably uses the SendInput API:
SendInput 在輸入堆棧的底層運行.它只是鍵盤和鼠標驅動程序用來告訴窗口管理器用戶生成輸入的相同輸入機制的后門.來源:http://blogs.msdn.com/b/oldnewthing/archive/2010/12/21/10107494.aspx
SendInput operates at the bottom level of the input stack. It is just a backdoor into the same input mechanism that the keyboard and mouse drivers use to tell the window manager that the user has generated input. Source: http://blogs.msdn.com/b/oldnewthing/archive/2010/12/21/10107494.aspx
因此可能無法判斷輸入是否來自真實"鍵盤.
So there is probably no way to tell whether the input is coming from a "real" keyboard or not.
這篇關于檢測模擬鍵盤/鼠標輸入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!