function KeyboardHookHandler(iCode: Integer;<br>wParam: WPARAM;<br>lParam: LPARAM ): LRESULT; stdcall; export;<br>const<br>_KeyPressMask = $80000000;<br>var<br>i:integer;<br>Key_S:String;<br>H:Thandle;<br>begin<br> Result := 0;<br> if R_point>0 then<br> begin<br> iCode:=-1;<br> R_point:=R_point-1;<br> end;<br> If iCode < 0 Then<br> begin<br> Result := CallNextHookEx(DnfNextHook, iCode, wParam, lParam);<br> Exit;<br> end;<br><br> for i:=0 to Key_.Count-1 do<br> begin <br> Key_S:=Key_;<br> if ((lParam and _KeyPressMask) = 0) and <br> (wParam = Ord(Key_S[1])) then <br> begin<br> Result := 1; <br> ///在这里处理我的活动窗口发送按钮,不成功SendMessage,PostMessage都不行<br> ///直接用keybd_event可以.<br> //如果打开记事本,当前窗口打开后,我按A按钮,响应的应该是在记事本里写上B<br> SetForegroundWindow(GetForegroundWindow);<br> SendMessage(GetActiveWindow,WM_KEYDOWN,66,0);<br> SendMessage(GetActiveWindow,WM_KEYUP,66,0);<br><br> end;<br> end;<br>end;