How do I make the combo box selection save to text file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tperry99
Posts: 2
Joined: 23 Mar 2017, 17:22

How do I make the combo box selection save to text file

23 Mar 2017, 17:46

Can someone help me. I first created a list, then wrote a script for a combo box using my list. When I make a selection in the box, I want it to create a text file with the variable name and then append whatever is on the clipboard into the file. I can's seem to get it to work. Help greatly appreciated.

Code: Select all

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
StringReplace, var, var, `r`n, , All
sleep 100
msgbox Text file will be named: %VAR%.txt
FILEAPPEND,
(
%clipboard%
), %A_ScriptDir%\%var%.txt
sleep 1000
;run %A_ScriptDir%\%var%.txt
return
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: How do I make the combo box selection save to text file

23 Mar 2017, 19:09

When I make a selection in the box
See glabel (https://autohotkey.com/docs/commands/Gui.htm#label) the documentation says:
Launches a subroutine or function automatically when the user clicks or changes a control
for instance in:

Code: Select all

Gui, Add, combobox, x10 y36 w500 h200 gTEST, a|b|c
subroutine TEST will be triggered on new selection on the combobox
also you don't especially have to submit in order to retrieve the associated output variable of the control ; within the scope of
the subroutine lunched by a g-label A_Guicontrol will content the selection (see: https://autohotkey.com/docs/Variables.htm#GuiControl)

Code: Select all

list := "alpha|beta|gamma|delta"
Gui, Add, Button, x425 y2 w40 h30, Write
Gui, Add, combobox, x10 y36 w500 h200 gTEST choose1, % list
Gui, Add, Text, x10 y3 w300 h30 , blabla... 
Gui, Show, AutoSize, ASR Field Information
Return

TEST:
FileAppend, % clipboard, % file:=(A_ScriptDir . "/" . A_GuiControl . ".txt"), utf-8
sleep, 100
run % A_WinDir . "/Notepad.exe" . A_Space . file
return

GuiClose:
ExitApp
my scripts
tperry99
Posts: 2
Joined: 23 Mar 2017, 17:22

Re: How do I make the combo box selection save to text file

23 Mar 2017, 20:05

Thanks for the suggestions. I am actually needing the button for some other reasons I plan to use. Is there a way to make that work?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen and 302 guests