1
votes

I am trying to make a text editor from autohotkey. Though, I am having trouble getting a button to insert text from a textbox into a file. Here is my code

Gui, Add, Picture, x2 y-1 w1360 h40 , chars\greenbox.png
Gui, Add, Tab, x2 y39 w1360 h660 , Untilted Project
Gui, Font, S8 CBlue Bold, Verdana
Gui, Add, Button, x2 y-1 w90 h20 vSave_text, Save
Gui, Add, Edit, x2 y59 w1350 h-90 vUsertextinput, Edit
Gui, Add, Edit, x2 y59 w1290 h580 , ';Created Using ADI
Gui, Font, S8 CGreen Bold, Verdana
Gui, Show, x200 y139 h666 w1370, ADI Editor
Return

GuiClose:
ExitApp

Save_text:

FileAppend,
(
%Usertextinput%
), Projects\Untitled1.ahk
1

1 Answers

2
votes

Your save button needs a g-label, not a variable, thus gSave_text.
To access the contents of the edit field you have to run GuiControlGet on it.

Here is a working example:

Gui, Add, Button, gSave_text, Save
Gui, Add, Edit, vUsertextinput, Test123
Gui, Show

Save_text() {
    GuiControlGet, Usertextinput
    FileAppend, %Usertextinput%, Projects\Untitled1.ahk
}