我创建了这个脚本来计算 mAh 和 mWh。当我输入值并按计算时,计算似乎正确。
但是,我无法弄清楚如何输入新值并点击计算,而无需手动重新启动脚本。有人可以帮我弄清楚缺少什么吗?
; Source(s)
; http://www.autoitscript.com/forum/topic/125495-guicreate-select-radio-button/
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Downloads\koda_2008-10-03\Forms\mWh2mAh.kxf
$Form1 = GUICreate("mAh mWh Calculator", 336, 210, 682, 127)
$capacity = GUICtrlCreateInput("", 224, 48, 81, 21)
GUICtrlSetCursor (-1, 0)
$mAh = GUICtrlCreateRadio("mAh", 224, 72, 41, 17)
GUICtrlSetCursor (-1, 0)
GUICtrlSetState ($mAh,$GUI_CHECKED)
$mWh = GUICtrlCreateRadio("mWh", 272, 72, 41, 17)
GUICtrlSetCursor (-1, 0)
$Volt=GUICtrlCreateInput("", 224, 96, 81, 21)
GUICtrlSetCursor (-1, 0)
$Calculate = GUICtrlCreateButton("Calculate", 104, 136, 75, 25)
$Input2 = GUICtrlCreateInput("", 184, 136, 121, 21)
GUICtrlSetState ($Input2, $GUI_DISABLE)
GUICtrlSetCursor (-1, 0)
$Label3 = GUICtrlCreateLabel("Calculate between milliampere-hour and milliwatt-hour", 16, 16, 304, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Select the appropriate radio button:", 48, 72, 170, 17)
$Label1 = GUICtrlCreateLabel("Enter the mAh or mWh value for the battery:", 8, 48, 211, 17)
$Label2 = GUICtrlCreateLabel("Enter the battery voltage:", 96, 96, 123, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Calculate
if GUICtrlRead($capacity)=0 then ExitLoop
if GUICtrlRead($Volt)=0 then ExitLoop
Switch GUICtrlRead($mAh)
Case $GUI_Checked ;mAh checked
$mAh = Int(GUICtrlRead($capacity))
$Ah = ($mAh/1000)
$Wh = ($Ah*(GUICtrlRead($Volt)))
$mWh = ($Wh*1000)
$myval = Int($mWh)&" mWh"
Case Else
EndSwitch
Switch GUICtrlRead($mWh)
Case $GUI_Checked ;mWh checked
$mWh = Int(GUICtrlRead($capacity))
$Wh = ($mWh/1000)
$Ah = ($Wh/(GUICtrlRead($Volt)))
$mAh = ($Ah*1000)
$myval = Int($mAh)&" mAh"
Case Else
EndSwitch
GUICtrlSetData(8, string($myval))
EndSwitch
WEnd