Page 1 of 1

"Inputting" GUI input into a program

Posted: 10 Jan 2020, 01:23
by Tmartyn
Hi Guys, new here, yay.

I've done a smattering of coding over the years but I'm really first encountering a lot of the language in AHK while trying to learn how to use it. Like a lot of people I learn by doing not reading >.<

I'm attempting to setup a GUI which will work as follows..
  • Person types #AHK into a text box in a program.
  • GUI window pops up.
  • Person reads instructions , types some things into certain Input Boxes in the GUI, presses GUI button.
  • Text is printed into the original text box, including the text put in the Input Box.
I hope that makes sense.

So far I've been able create input in other hotkeys, as well as making the gui and the buttons, but I can't work out how to take the text from the input box and put it into the text.

Re: "Inputting" GUI input into a program

Posted: 10 Jan 2020, 09:08
by TheDewd
Try this:

Code: Select all

#SingleInstance, Force
#Persistent

Gui, Margin, 10, 10
Gui, Add, Edit, w200 r1 vEdit1
Gui, Add, Edit, w200 r1 vEdit2
Gui, Add, Edit, w200 r1 vEdit3
Gui, Add, Edit, w200 r1 vEdit4
Gui, Add, Edit, w200 r1 vEdit5
Gui, Add, Button, w200 r1 gSubmitForm, OK
Gui, Show, Hide Autosize, Example
return

SubmitForm:
	Gui, Submit
	Str := "Field 1: " Edit1 "`nField 2: " Edit2 "`nField 3: " Edit3 "`nField 4: " Edit4 "`nField 5: " Edit5
	Send, % Str
return

:*:#AHK::
	Gui, Show
return

Re: "Inputting" GUI input into a program

Posted: 04 Jan 2022, 03:45
by hamsolo474
In order to get this code to run as soon as the script is opened i had to change one line, however you can run the original by typing #AHK

Code: Select all

#SingleInstance, Force
#Persistent

Gui, Margin, 10, 10
Gui, Add, Edit, w200 r1 vEdit1
Gui, Add, Edit, w200 r1 vEdit2
Gui, Add, Edit, w200 r1 vEdit3
Gui, Add, Edit, w200 r1 vEdit4
Gui, Add, Edit, w200 r1 vEdit5
Gui, Add, Button, w200 r1 gSubmitForm, OK
Gui, Show, Hide Autosize, Example
Gui, Show
return

SubmitForm:
	Gui, Submit
	Str := "Field 1: " Edit1 "`nField 2: " Edit2 "`nField 3: " Edit3 "`nField 4: " Edit4 "`nField 5: " Edit5
	Send, % Str
return

:*:#AHK::
	Gui, Show
return