找回密码
 加入
搜索
查看: 5847|回复: 5

如何將GUI輸入的數據寫入INI的文件

[复制链接]
发表于 2009-3-3 14:29:41 | 显示全部楼层 |阅读模式
我在GUI有三個輸入視窗,如圖1所示,希望每按一次"Enter"就把數據寫入INI的文件裡,例如第一次輸入AAA;www.google.com;www.yahoo.com等三個數據,INI文件要依序填入,如圖2所示,
第二次輸入BBB;www.google1.com;www.yahoo1.com等三個數據但是不能覆蓋掉之前第一次輸入的數據,依此類推之後的輸入,如圖3所示,,請問,該如何寫這段代碼?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Array.au3>


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form1", 800, 398, 61, 182)

$IName = GUICtrlCreateLabel("Name", 20, 48, 46, 22);左側 上方 寬 高
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input1 = GUICtrlCreateInput("Input Name", 80, 48,200, 22)
$Address = GUICtrlCreateLabel("URL", 20, 98, 46, 22);左側 上方 寬 高
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("Input URL", 80, 98,250, 22)
$PicAddress = GUICtrlCreateLabel("PIC_URL", 20, 148, 46, 22);左側 上方 寬 高
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("Input PIC_URL", 80, 148,250, 22)
$Button10 = GUICtrlCreateButton("Enter", 500, 114, 80, 30, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd


[ 本帖最后由 fancky 于 2009-3-3 16:14 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-3-3 15:02:03 | 显示全部楼层
这位同胞 我想
您很有必要看看帮助 尤其是关于IniWrite方面的介绍
发表于 2009-3-3 15:13:16 | 显示全部楼层

正好有空,你看看。

$Form1 = GUICreate("Form1", 800, 398, 61, 182)
GUICtrlCreateLabel("Name", 20, 48, 46, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input1 = GUICtrlCreateInput("Input Name", 80, 48,200, 22)
GUICtrlCreateLabel("URL", 20, 98, 46, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("Input URL", 80, 98,250, 22)
GUICtrlCreateLabel("PIC_URL", 20, 148, 46, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input3 = GUICtrlCreateInput("Input PIC_URL", 80, 148,250, 22)
$Button1 = GUICtrlCreateButton("Enter", 500, 114, 80, 30, 0)
GUISetState()

$Value = -1
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
                Case $Button1
                        $Value += 1
                        IniWrite(@ScriptDir&"\Config.ini", "Name", "Name"&$Value, GUICtrlRead($Input1))
                        IniWrite(@ScriptDir&"\Config.ini", "Address", "Address"&$Value, GUICtrlRead($Input2))
                        IniWrite(@ScriptDir&"\Config.ini", "ImageAddress", "ImageAddress"&$Value, GUICtrlRead($Input3))
     EndSwitch
WEnd
 楼主| 发表于 2009-3-3 16:14:35 | 显示全部楼层
原來是要加上$Value += 1,不然我每次寫入都只有一行,而且都會被蓋住上一次的數值,感謝您的解答,我懂了。
发表于 2012-12-5 11:29:50 | 显示全部楼层
发表于 2014-7-31 09:52:12 | 显示全部楼层
感谢,学习了,学习了,学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 04:26 , Processed in 0.078737 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表