Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 自动热键将combobox变量存储为文本文件名_User Interface_Combobox_Text Files_Autohotkey_Submit Button - Fatal编程技术网

User interface 自动热键将combobox变量存储为文本文件名

User interface 自动热键将combobox变量存储为文本文件名,user-interface,combobox,text-files,autohotkey,submit-button,User Interface,Combobox,Text Files,Autohotkey,Submit Button,首先,我能够从我电脑上的列表中创建一个组合框。然后,我尝试从组合框中选择一个项目,将其存储为变量,创建一个具有该变量名称的文本文件,并将剪贴板内容附加到该文件中。我的脚本将执行此操作,但仅限于组合框中的最后一个选择。我想让它与任何选定的项目。请帮帮我 Fileread, List, %A_ScriptDir%\My List.txt Sort, List Gui, Add, Button, x425 y2 w40 h30 , Write Gui +Delimiter`n Gui, Add, co

首先,我能够从我电脑上的列表中创建一个组合框。然后,我尝试从组合框中选择一个项目,将其存储为变量,创建一个具有该变量名称的文本文件,并将剪贴板内容附加到该文件中。我的脚本将执行此操作,但仅限于组合框中的最后一个选择。我想让它与任何选定的项目。请帮帮我

Fileread, List, %A_ScriptDir%\My List.txt
Sort, List
Gui, Add, Button, x425 y2 w40 h30 , Write
Gui +Delimiter`n
Gui, Add, combobox, x10 y36 w500 h200 vVar, %list%
Gui, Add, Text, x10 y3 w300 h30 , Select one of  the file names from the dropdown list. Then press "Write" to paste clipboard contents to a new or existing text file.
Gui, Show, AutoSize, ASR Field Information
Return

ButtonWrite:
gui, submit, nohide
sleep 100
msgbox Text file will be named: %VAR%.txt
FILEAPPEND,
(
%clipboard%
), %A_ScriptDir%\%var%.txt
sleep 1000
run %A_ScriptDir%\var.txt
return

在我修复了几个小错误后,您的脚本似乎按照您的预期工作:

修复:

...
var := trim(var, " `t`r`n")                   ; trim trailing LF/CR
msgbox Text file will be named: %VAR%.txt
...
run %A_ScriptDir%\%var%.txt                   ; added %'s to expand var
...
My List.txt

Alpha
Beta
Delta
Gamma

我将文本复制到剪贴板,重新加载自动热键以运行代码,从下拉列表中选择“Alpha”(我文件中的第一行),然后按下写入按钮。MsgBox说“文本文件将命名为:Alpha.txt”,然后Alpha.txt打开,并将我的剪贴板文本附加到末尾

文字不表达我的感激之情!谢谢。不客气:)。如果你发现这个答案是有用的,请考虑它的投票(标记它是有用的)。如果它也回答了您的问题,并且是最好的解决方案,请也勾选它为已接受。这些反馈功能可以帮助有类似问题的人找到有用的解决方案。它还承认并鼓励捐助者