fancky 发表于 2009-3-3 14:29:41

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

我在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

fancky 发表于 2009-3-3 16:14:35

原來是要加上$Value += 1,不然我每次寫入都只有一行,而且都會被蓋住上一次的數值,感謝您的解答,我懂了。

au3x 发表于 2012-12-5 11:29:50

{:face (249):}

ak47gglllk 发表于 2014-7-31 09:52:12

感谢,学习了,学习了,学习了
页: [1]
查看完整版本: 如何將GUI輸入的數據寫入INI的文件