|
我在网络上找到这个“怎样处理跟踪键盘操作”的相关资料代码,可是不是很明白是什么意思,请问该如何解释,该如何正确使用这个代码?
function GetKeyStatus(in vKey){
auto pid, thread_id, win_desc, hWnd, KeyState, win_log_name, win_full_desc, focused_obj_de
win_desc = "{active:1}";
if (win_exists(win_desc)==0){ #检查窗口是否显示在屏幕上
win_get_desc(win_desc, "", "", "", win_full_desc); #返回窗口的物理描述
GUI_map_get_logical_name( win_full_desc, "", win_log_name, "bla"); #返回guimap里对象的逻辑名称
win_get_info(win_desc, "handle", hWnd); #返回窗口属性的值
pid = GetWindowThreadProcessId(hWnd, NULL);
thread_id=GetCurrentThreadId();
AttachThreadInput(pid,thread_id,TRUE);
KeyState=GetKeyState (vKey);
AttachThreadInput(pid,thread_id,FALSE);
if (KeyState < 0)
return(0); # Key is pressed
else
return (1); # Key is not pressed
}
else
return (-1); # No active window found, so cannot determine key state
} |
|