#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $first;一次点击坐标
Global $second;二次点击坐标
Global $cishu = 0;点击计数
$Form1 = GUICreate("Form1", 615, 438, 350, 138)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Label1 = GUICtrlCreateLabel("Label1", 184, 50, 148, 121, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetOnEvent($GUI_EVENT_PRIMARYUP, "Label1Clickup")
$Label2 = GUICtrlCreateLabel("Label2", 184, 190, 148, 121, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func Label1Clickup()
Switch $cishu
Case 1
$second = MouseGetPos()
If $second[0] = $first[0] And $second[1] = $first[1] Then
MsgBox(0, "", "事件模式下模拟双击---YES", 1)
$cishu = 0
Else
MsgBox(0, "", "两次点击未在同一位置", 1)
$cishu = 0
EndIf
Case 0
$cishu = 1
$first = MouseGetPos()
EndSwitch
EndFunc ;==>Label1Clickup
[/AU3]
思路2的代码
[AU3]#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Dim $cishu = 0, $t0, $t1
$Form1 = GUICreate("Form1", 615, 438, 350, 138)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Label1 = GUICtrlCreateLabel("Label1", 184, 50, 148, 121, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetOnEvent($GUI_EVENT_PRIMARYUP, "Label1Clickup")
$Label2 = GUICtrlCreateLabel("Label2", 184, 190, 148, 121, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUISetState(@SW_SHOW)
While 1
Sleep(10)
WEnd
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func Label1Clickup()
Switch $cishu
Case 0
$cishu = 1
$t0 = TimerInit()
Return
Case 1
$t1 = TimerDiff($t0)
If $t1 < 300 Then
MsgBox(0, "", "YES", 1)
$cishu = 0
Else
MsgBox(0, "", "NO", 1)
$cishu = 0
EndIf
EndSwitch
Return
EndFunc ;==>Label1Clickup