【已解决】请教根据单选框选择及输入框内容保存至ini
本帖最后由 hxx006 于 2016-3-7 01:13 编辑初学,容易犯低级错误,请大家担待。
做了一个窗口,后续弄不了,弄到半夜,实在瞌睡,明天上班,请大家帮帮忙,检查下,提点建议或者修改下,不甚感激!
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("时间设置", 346, 155, 403, 203)
$Radio1 = GUICtrlCreateRadio("Radio1", 64, 128, 17, 17)
$Radio2 = GUICtrlCreateRadio("Radio1", 64, 56, 17, 17)
$Radio3 = GUICtrlCreateRadio("Radio1", 64, 80, 17, 17)
$Radio4 = GUICtrlCreateRadio("Radio1", 64, 104, 17, 17)
$Label1 = GUICtrlCreateLabel("快速", 16, 56, 28, 17)
$Label2 = GUICtrlCreateLabel("1分钟", 16, 80, 34, 17)
$Label3 = GUICtrlCreateLabel("5分钟", 16, 104, 34, 17)
$Label4 = GUICtrlCreateLabel("10分钟", 16, 128, 40, 17)
$Label5 = GUICtrlCreateLabel("快速选择", 16, 32, 52, 17)
$Label6 = GUICtrlCreateLabel("设置时间", 112, 32, 52, 17)
$time = GUICtrlCreateInput("time", 112, 56, 57, 21)
$Button1 = GUICtrlCreateButton("确定", 112, 96, 57, 49)
$Label7 = GUICtrlCreateLabel("每用户登录保留时间设定", 16, 8, 136, 17)
$Button2 = GUICtrlCreateButton(" 启动", 272, 40, 57, 25)
$Label8 = GUICtrlCreateLabel("硬件ID计算", 200, 40, 63, 17)
$Label10 = GUICtrlCreateLabel("智慧银行自动登录运行", 200, 72, 124, 17)
$Button3 = GUICtrlCreateButton("启动", 200, 96, 57, 49)
$Button4 = GUICtrlCreateButton("停止", 272, 96, 57, 49)
$Label11 = GUICtrlCreateLabel("帮助及介绍", 200, 8, 64, 17)
$Button5 = GUICtrlCreateButton("查看", 272, 8, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Local $FileExists = FileExists(@ScriptDir & "\time.ini");判断time配置文件是否存在.
If$FileExists Then
$time1 = IniRead(@ScriptDir & "\time.ini", "time", "time",8000)
$time = $time1 / 1000
Else
IniWrite(@ScriptDir&"\file.ini","time","time","8000")
EndIf
if GUICtrlRead($Radio1) = $GUI_CHECKED Then
IniWrite(@ScriptDir&"\file.ini","time","time","8000")
EndIf
if GUICtrlRead($Radio2) = $GUI_CHECKED Then
IniWrite(@ScriptDir&"\file.ini","time","time","60000")
EndIf
if GUICtrlRead($Radio3) = $GUI_CHECKED Then
IniWrite(@ScriptDir&"\file.ini","time","time","300000")
EndIf
if GUICtrlRead($Radio4) = $GUI_CHECKED Then
IniWrite(@ScriptDir&"\file.ini","time","time","600000")
EndIf
$time = GUICtrlCreateInput("", 55, 35, 41, 21,$ES_NUMBER);输入框只可输入数字
;判断输入框是否有数据输入
;有输入则保存输入框内容到ini文件
EndSwitch
WEnd
;8000为另一脚本用,8000表示8秒
1、先判断ini文件是否存在,不存在则新建time.ini文件,格式为
time=8000
存在则读取time值/1000到输入框
8000为8秒
选择“快速“直接写ini为8000,不点确定;选择1分钟为60000,以此类推。
2、设置输入框只能输入数字,单位为秒
判断输入框是否有数据输入,有则点击确定后保存到到time值*1000
请大家帮帮忙 还有很多要学,先自行研究下#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("时间设置", 346, 155, 403, 203)
$Radio1 = GUICtrlCreateRadio("快速", 16, 56, 50, 17)
GUICtrlSetState(-1, 1)
$Radio2 = GUICtrlCreateRadio("1分钟", 16, 80, 50, 17)
$Radio3 = GUICtrlCreateRadio("5分钟", 16, 104, 50, 17)
$Radio4 = GUICtrlCreateRadio("10分钟", 16, 128, 50, 17)
$Label5 = GUICtrlCreateLabel("快速选择", 16, 32, 52, 17)
$Label6 = GUICtrlCreateLabel("设置时间", 112, 32, 52, 17)
$time = GUICtrlCreateInput("", 112, 56, 57, 21, 0x2000) ;$ES_NUMBER = 0x2000 输入框只可输入数字
$Button1 = GUICtrlCreateButton("确定", 112, 96, 57, 49)
$Label7 = GUICtrlCreateLabel("每用户登录保留时间设定", 16, 8, 136, 17)
$Button2 = GUICtrlCreateButton(" 启动", 272, 40, 57, 25)
$Label8 = GUICtrlCreateLabel("硬件ID计算", 200, 40, 63, 17)
$Label10 = GUICtrlCreateLabel("智慧银行自动登录运行", 200, 72, 124, 17)
$Button3 = GUICtrlCreateButton("启动", 200, 96, 57, 49)
$Button4 = GUICtrlCreateButton("停止", 272, 96, 57, 49)
$Label11 = GUICtrlCreateLabel("帮助及介绍", 200, 8, 64, 17)
$Button5 = GUICtrlCreateButton("查看", 272, 8, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$fIni = @ScriptDir & "\time.ini"
If Not FileExists($fIni) Then IniWrite($fIni, 'time', 'time', '8000')
GUICtrlSetData($time, IniRead($fIni, 'time', 'time', '8000') / 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Radio1
GUICtrlSetData($time, 8)
Case $Radio2
GUICtrlSetData($time, 60)
Case $Radio3
GUICtrlSetData($time, 300)
Case $Radio4
GUICtrlSetData($time, 600)
EndSwitch
WEnd 非常感谢斑竹,能腾出时间给予新手无私的帮助。现已补全代码,并测试成功,再次感谢。#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("自动登录", 346, 155, 403, 203)
$Radio1 = GUICtrlCreateRadio("快速", 16, 56, 50, 17)
GUICtrlSetState(-1, 1)
$Radio2 = GUICtrlCreateRadio("1分钟", 16, 80, 50, 17)
$Radio3 = GUICtrlCreateRadio("5分钟", 16, 104, 50, 17)
$Radio4 = GUICtrlCreateRadio("10分钟", 16, 128, 50, 17)
$Label5 = GUICtrlCreateLabel("快速选择", 16, 32, 52, 17)
$Label6 = GUICtrlCreateLabel("单位为秒", 112, 32, 52, 17)
$Input1 = GUICtrlCreateInput("", 112, 56, 57, 21, 0x2000) ;$ES_NUMBER = 0x2000 输入框只可输入数字
$Button1 = GUICtrlCreateButton("确定", 112, 96, 57, 49)
$Label7 = GUICtrlCreateLabel("每用户登录保留时间设定", 16, 8, 136, 17)
$Button2 = GUICtrlCreateButton(" 启动", 272, 40, 57, 25)
$Label8 = GUICtrlCreateLabel("硬件ID计算", 200, 40, 63, 17)
$Label10 = GUICtrlCreateLabel("智慧银行自动登录运行", 200, 72, 124, 17)
$Button3 = GUICtrlCreateButton("启动", 200, 96, 57, 49)
$Button4 = GUICtrlCreateButton("停止", 272, 96, 57, 49)
$Label11 = GUICtrlCreateLabel("帮助及介绍", 200, 8, 64, 17)
$Button5 = GUICtrlCreateButton("查看", 272, 8, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$fIni = @ScriptDir & "\time.ini"
If Not FileExists($fIni) Then IniWrite($fIni, 'time', 'time', '8000')
GUICtrlSetData($Input1, IniRead($fIni, 'time', 'time', '8000') / 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Radio1
GUICtrlSetData($Input1, 8)
Case $Radio2
GUICtrlSetData($Input1, 60)
Case $Radio3
GUICtrlSetData($Input1, 300)
Case $Radio4
GUICtrlSetData($Input1, 600)
Case $Button1
IniWrite($fIni, 'time', 'time',GUICtrlRead($Input1) *1000)
EndSwitch
WEnd
页:
[1]