本帖最后由 半芯竹 于 2012-1-11 16:39 编辑 ;检索具有键盘焦点的窗口句柄 :_WinAPI_GetFocus()
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $gui, $msg, $btnFocus, $win, $text
$gui = GUICreate("__WinAPI_GetFocus Example", 200, 200)
$btnFocus = GUICtrlCreateButton("Get Focus", 50, 85, 100, 30)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $btnFocus
$win = _WinAPI_GetFocus()
$text = "Full Title: " & WinGetTitle($win) & @LF
$text &= "Full Text: " & WinGetText($win) & @LF
$text &= "Handle: " & WinGetHandle($win) & @LF
$text &= "Process: " & WinGetProcess($win) & @LF
MsgBox(0, "", $text)
EndSelect
WEnd
EndFunc ;==>_Main
你可以修改代码为循环检测…… |