#include <GUIConstantsEx.au3>
Dim $P = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
Dim $Ico = $P & '\Aut2Exe\Icons\strawberry.ico'
$formh = GUICreate('test', 350, 130)
$cIco = GUICtrlCreateIcon($Ico, -1, 200, 50, 32, 32)
GUICtrlCreateLabel("心跳速率 (次/分钟)", 8, 70, 60, 30)
GUICtrlCreateLabel("心跳变率 (次/分钟)", 8, 100, 60, 30)
GUICtrlCreateLabel("心跳最高值(次/分钟)", 8, 40, 60, 30)
GUICtrlCreateLabel("心跳最低值(次/分钟)", 8, 10, 60, 30)
$edit0 = GUICtrlCreateEdit("", 75, 10, 40, 18, 0x2000)
$edit1 = GUICtrlCreateEdit("", 75, 40, 40, 18, 0x2000)
$edit2 = GUICtrlCreateEdit("", 75, 70, 40, 18, 0x2000)
$edit3 = GUICtrlCreateEdit("", 75, 100, 40, 18, 0x2000)
$bu_chang = GUICtrlCreateButton("输入初始参数", 140, 40, 50, 50, 0x3300)
GUICtrlSetState($edit0, $GUI_DISABLE)
GUICtrlSetState($edit1, $GUI_DISABLE)
GUICtrlSetState($edit2, $GUI_DISABLE)
GUICtrlSetState($edit3, $GUI_DISABLE)
GUISetState()
Global $hartdata[5] = [60, 100, 80, 0, 1]
Global $icorect[2] = [30, 60]
$input = 0
AdlibRegister('pengpeng', 50)
$jstime = TimerInit()
$lastetime = TimerDiff($jstime)
$runt = 0
While 1
$runt += 1
If $runt > 500 Then
If $hartdata[3] > 0 Then
$hartdata[3] -= Random(0,5,1)
Else
$hartdata[3] += Random(0,5,1)
EndIf
$runt = 0
EndIf
If $hartdata[4] = 3 Then
If Not IsDeclared("scl") Then $scl = 0
If $scl <> 11 Then
$scl = MsgBox(86, " ~@^@~", " 心跳超出承受范围!!" & @CRLF & " 你玩完啦!!")
Switch $scl
Case 2
;$hartdata[0] = 60
;$hartdata[1] = 100
$hartdata[2] = $hartdata[1]
$hartdata[3] = 0
$hartdata[4] = 1
Case 10
$hartdata[0] = 60
$hartdata[1] = 100
$hartdata[2] = 80
$hartdata[3] = 0
$hartdata[4] = 1
Case 11
;$hartdata[0] =
;$hartdata[1] =
;$hartdata[2] =
;$hartdata[3] =
;$hartdata[4] =
Case Else
$scl = 11
EndSwitch
EndIf
EndIf
$nMsg = GUIGetMsg(1)
If $input = 0 Then
GUICtrlSetData($edit0, $hartdata[0])
GUICtrlSetData($edit1, $hartdata[1])
GUICtrlSetData($edit2, $hartdata[2])
GUICtrlSetData($edit3, $hartdata[3])
EndIf
Switch $nMsg[0]
Case -3
Exit
Case $cIco
Case $GUI_EVENT_PRIMARYDOWN
If Not IsDeclared("clickt") Then
$clickt = TimerInit()
$mdbclick = False
Else
$ctds = TimerDiff($clickt)
If $ctds < 1000 Then
$mdbclick = True
Else
$mdbclick = False
EndIf
$clickt = TimerInit()
EndIf
$msinfo = GUIGetCursorInfo($formh)
If $msinfo[4] = $cIco Then
If $mdbclick Then
$hartdata[3] = 0
Else
$hartdata[3] += 1
EndIf
EndIf
Case $GUI_EVENT_SECONDARYDOWN
$msinfo = GUIGetCursorInfo($formh)
If $msinfo[4] = $cIco Then
$hartdata[3] -= 1
EndIf
Case $bu_chang
If $input Then
GUICtrlSetData($bu_chang, "输入初始参数")
$input = 0
GUICtrlSetState($edit0, $GUI_DISABLE)
GUICtrlSetState($edit1, $GUI_DISABLE)
GUICtrlSetState($edit2, $GUI_DISABLE)
GUICtrlSetState($edit3, $GUI_DISABLE)
$hartdata[0] = GUICtrlRead($edit0)
$hartdata[1] = GUICtrlRead($edit1)
$hartdata[2] = GUICtrlRead($edit2)
$hartdata[3] = GUICtrlRead($edit3)
$hartdata[4] = 1
$scl = 0
Else
GUICtrlSetData($bu_chang, "确定")
$input = 1
GUICtrlSetState($edit0, $GUI_ENABLE)
GUICtrlSetState($edit1, $GUI_ENABLE)
GUICtrlSetState($edit2, $GUI_ENABLE)
GUICtrlSetState($edit3, $GUI_ENABLE)
EndIf
EndSwitch
WEnd
Func pengpeng()
Local $hartpos[4] = [250, 60, 0, 0]
If $hartdata[4] = 3 Then Return SetError(1, 0, 0)
$hartodpos = ControlGetPos($formh, "", $cIco)
$distance = TimerDiff($jstime) - $lastetime
$addtimes = $hartdata[3] * $distance / 6000
$hartdata[2] += $addtimes
If $hartdata[2] > $hartdata[1] Then
$hartdata[4] = 3
EndIf
If $hartdata[2] < $hartdata[0] Then
$hartdata[4] = 3
EndIf
$hicomax = $icorect[1]
$hicomin = $icorect[0]
$hicocrmax = 0.5 * ($icorect[1] - $icorect[0]) * ($hartdata[2] - $hartdata[0]) / ($hartdata[1] - $hartdata[0]) + $icorect[0] + (0.5 * ($icorect[1] - $icorect[0]))
$hicocrn = $hartodpos[3]
$icoadd = ($hicocrmax - $hicomin) * 2 * $distance / (1000 * 60 / $hartdata[2])* Random(0.8,1.2)
Switch $hartdata[4]
Case 1
$hicocrn += $icoadd
If $hicocrn >= $hicocrmax Then
$hartdata[4] = 0
$hicocrn = $hicocrmax
EndIf
Case 0
$hicocrn -= $icoadd
If $hicocrn <= $hicomin Then
$hartdata[4] = 1
$hicocrn = $hicomin
EndIf
Case 3
Case Else
MsgBox(0, "", "不知道你心在干什么!!")
Exit
EndSwitch
$hartpos[2] = $hartpos[0] - Round($hicocrn / 2)
$hartpos[3] = $hartpos[1] - Round($hicocrn / 2)
GUICtrlSetPos($cIco, $hartpos[2], $hartpos[3], $hicocrn, $hicocrn)
$lastetime = TimerDiff($jstime)
EndFunc ;==>pengpeng