本帖最后由 飘云 于 2010-12-29 17:20 编辑
回复 1# xuanfeng1234567
很粗糙很简陋,我的思路就是这样,具体自己改进吧
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode",1)
$main = GUICreate("鼠标检测-Esc键退出窗口",300,300,-1,-1,BitOR($WS_POPUP,$WS_BORDER))
$Label = GUICtrlCreateLabel("",100,100,150,17)
$minfo = GUICtrlCreateLabel("",100,130,150,17)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
GUISetState()
While 1
Sleep(100)
$mpos = MouseGetPos()
$wpos = WinGetPos($main)
If $mpos[0]>=$wpos[0] And $mpos[0]<=($wpos[0]+$wpos[2]) And $mpos[1]>=$wpos[1] And $mpos[1]<=($wpos[1]+$wpos[3]) And WinActive($main) Then
GUICtrlSetData($Label,"鼠标在窗口内")
Else
GUICtrlSetData($Label,"鼠标不在窗口内")
EndIf
GUICtrlSetData($minfo,"鼠标x:"&$mpos[0]&"鼠标y:"&$mpos[1])
WEnd
Func main()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndFunc
|