#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
Global $g_tRECT, $g_iIndex, $g_hMenu = 0
Global $hForm, $hEventProc, $hEventHook, $a_idInput[11]
Example()
Func Example()
$hForm = GUICreate('', 240, 268, 10, 10, BitOR($WS_CAPTION, $WS_POPUP), $WS_EX_TOPMOST)
GUICtrlCreateLabel('线程状态:', 20, 18, 90, 14)
GUICtrlCreateLabel('活动窗口:', 20, 40, 90, 14)
GUICtrlCreateLabel('键盘焦点:', 20, 62, 90, 14)
GUICtrlCreateLabel('鼠标捕获:', 20, 84, 90, 14)
GUICtrlCreateLabel('活动菜单:', 20, 106, 90, 14)
GUICtrlCreateLabel('移动或大小循环:', 20, 128, 90, 14)
GUICtrlCreateLabel('插入符号:', 20, 150, 90, 14)
GUICtrlCreateLabel('左距:', 20, 172, 90, 14)
GUICtrlCreateLabel('顶距:', 20, 194, 90, 14)
GUICtrlCreateLabel('宽度:', 20, 216, 90, 14)
GUICtrlCreateLabel('高度:', 20, 238, 90, 14)
For $i = 0 To 10
$a_idInput[$i] = GUICtrlCreateLabel('', 114, 18 + 22 * $i, 116, 14)
Next
GUISetState(@SW_SHOWNOACTIVATE)
$hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
$hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_FOREGROUND, $EVENT_OBJECT_FOCUS, DllCallbackGetPtr($hEventProc))
OnAutoItExitRegister('OnAutoItExit')
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
#forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime
Local $aInfo
If $iEvent = $EVENT_OBJECT_FOCUS Or $iEvent = $EVENT_SYSTEM_FOREGROUND Then
$aInfo = _WinAPI_GetGUIThreadInfo(Null)
For $i = 0 To 10
If StringCompare(GUICtrlRead($a_idInput[$i]), $aInfo[$i]) Then
GUICtrlSetData($a_idInput[$i], $aInfo[$i])
EndIf
Next
WinSetTitle($hForm, '', WinGetTitle($hWnd))
EndIf
EndFunc ;==>_EventProc
Func OnAutoItExit()
_WinAPI_UnhookWinEvent($hEventHook)
DllCallbackFree($hEventProc)
EndFunc ;==>OnAutoItExit
是不是浏览器接管了键盘焦点管理,无法通过外部方法干预。