使用FileAppend在两个文件之间插入下拉列表内容

时间:2016-01-11 05:19:35

标签: autohotkey

我无法将DDL(下拉列表)内容与名为topCode.txtbottomCode.txt的两个文件的内容一起附加。如何在这两个文件之间放置DDL内容?这是我的代码:

Gui, Color, 008AB8
Gui 1:Show, x131 y91 h379 w479, Rotation Helper

Gui, Add, DropDownList,x76 y27 w50 h20 r10 gLoad vDDL, 1||2|3
Gui, Add, Text, x16 y27 w50 h20 +Center, Number

Gui, Add, Edit, x76 y57 w50 h20 vhotkey,
Gui, Add, Text, x16 y57 w50 h20 +Center, Hotkey

Gui, Add, Edit, x76 y87 w50 h20 vcolor,
Gui, Add, Text, x16 y87 w50 h20 +Center, Color

Gui, Add, Edit, x76 y117 w50 h20 vX1,
Gui, Add, Text, x16 y117 w50 h20 +Center, X1

Gui, Add, Button, x146 y337 w100 h30 gClear, Clear Enteries
Gui, Add, Button, x256 y337 w100 h30 gSave, Save
Gui, Add, Button, x366 y337 w90 h30 gLoad, Load
Gui, Add, GroupBox, x6 y7 w450 h250 , Settings

return

Clear:
GuiControl, , hotkey, %Subject%
GuiControl, , color, %Subject%
GuiControl, , X1, %Subject%


Return

Save:
Gui, Submit, NoHide

IniWrite,%hotkey%, %a_Workingdir%\Iniread.ini, List%DDL%, List1
IniWrite,%color%, %a_Workingdir%\Iniread.ini, List%DDL%, List2
IniWrite,%X1%, %a_Workingdir%\Iniread.ini, List%DDL%, List3


return

Load:
Gui, Submit, NoHide

Iniread, Read, %a_workingdir%\Iniread.ini, List%DDL%, List1
Iniread,Read2, %a_Workingdir%\Iniread.ini, List%DDL%, List2
Iniread,newX1, %a_Workingdir%\Iniread.ini, List%DDL%, List3


GuiControl,, hotkey, %Read%
GuiControl,, color, %Read2%
GuiControl,, X1, %newX1%

NewColor = PixelSearch, %AbilityNameX%, %AbilityNameY%, %newX1%, %newY1%, %newX2%, %newY2%, %Read2%, 3, Fast if !ErrorLevel SendInput {%Read% down}{%Read% up}
FileRead, topCode, %A_ScriptDir%\topCode.txt
FileRead, bottomCode, %A_ScriptDir%\bottomCode.txt

FileAppend,
(
%topCode%,%NewColor%,%bottomCode%
), %A_ScriptDir%\PasteToRotationFile.ahk

return

1 个答案:

答案 0 :(得分:1)

文件内容低于Load:标签,因此每次使用“加载”按钮时都会执行该操作。并且FileAppend 会将添加到文件中,因此您必须先将删除

你的文件部分应该像这样(猜测):

NewColor = PixelSearch, %AbilityNameX%, %AbilityNameY%, %newX1%, %newY1%, %newX2%, %newY2%, %Read2%, 3, Fast if !ErrorLevel SendInput {%Read% down}{%Read% up}  
FileRead, topCode, %A_ScriptDir%\topCode.txt
FileRead, bottomCode, %A_ScriptDir%\bottomCode.txt
FileDelete, %A_ScriptDir%\PasteToRotationFile.ahk
FileAppend,
(
%topCode%,%NewColor%,%bottomCode%
), %A_ScriptDir%\PasteToRotationFile.ahk

改善你的问题,我会调整这个答案。