問(wèn)題描述
有沒(méi)有辦法檢測(cè) Windows 上的模擬鍵盤/鼠標(biāo)輸入.例如,用戶在他的鍵盤上輸入一些東西,而不是 sendKeys/PostMessage/屏幕鍵盤.有沒(méi)有辦法區(qū)分這兩者?
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?
也許一個(gè)例子會(huì)有所幫助.我正在制作游戲并想?yún)^(qū)分真實(shí)輸入與 WinAPI 合成鍵盤/鼠標(biāo)消息.
Perhaps an example would help. I am making a game and want to distinguish between real input vs WinAPI synthesizing keyboard/mouse messages.
推薦答案
我可能錯(cuò)了,但屏幕鍵盤(和其他模擬用戶輸入的應(yīng)用程序)很可能使用 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 在輸入堆棧的底層運(yùn)行.它只是鍵盤和鼠標(biāo)驅(qū)動(dòng)程序用來(lái)告訴窗口管理器用戶生成輸入的相同輸入機(jī)制的后門.來(lái)源: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
因此可能無(wú)法判斷輸入是否來(lái)自真實(shí)"鍵盤.
So there is probably no way to tell whether the input is coming from a "real" keyboard or not.
這篇關(guān)于檢測(cè)模擬鍵盤/鼠標(biāo)輸入的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!