本帖最后由 yuantian 于 2020-3-23 23:29 编辑
我简单的改了一下,然后还有个问题就是Sleep的时间你还需要重新琢磨一下。。
#include <WindowsConstants.au3>
Global Const $GUI_EVENT_EXIT = -3
Opt("GUIOnEventMode", 1)
Global $mainForm = GUICreate("不关闭屏幕及睡眠", 200, 50, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) ;创建窗口
GUISetOnEvent($GUI_EVENT_EXIT, "EVENT_HANDLE")
$Input = GUICtrlCreateInput("60", 10, 10, 50, 20)
GUICtrlCreateLabel("分钟", 70, 15, 40, 20)
$btn = GUICtrlCreateButton("开始计时", 120, 10, 60, 20)
GUICtrlSetOnEvent($btn, "EVENT_HANDLE")
GUISetState(@SW_SHOW) ;显示窗口
While 1
Sleep(1000)
WEnd
GUIDelete()
Func EVENT_HANDLE()
Opt('GUIOnEventMode', 0)
Switch @GUI_CtrlId
Case $GUI_EVENT_EXIT
Exit
Case $btn
$dis = GUICtrlRead($Input)
For $i = 1 To $dis * 30 * 10
$ts = TimerInit()
Do
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
Until TimerDiff($ts) > 500
Local $aPos = MouseGetPos()
If Mod($i, 100) = 0 Then MouseMove($aPos[0] + 10, $aPos[1])
Sleep(100)
Local $bPos = MouseGetPos()
If Mod($i, 100) = 50 Then MouseMove($bPos[0] - 10, $bPos[1])
Sleep(100)
Next
EndSwitch
EndFunc ;==>EVENT_HANDLE
|