Something like this is how I'd do it.
#include <GUIConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1)
Global $g_idExit
_Main()
Func _Main()
Global $GUI1 = GUICreate("Template", 450, 150)
$idPM11031 = GUICtrlCreateButton("CTE", 10, 30, 100, 30)
GUICtrlSetOnEvent($idPM11031, "PM11031")
$g_idExit = GUICtrlCreateButton("Exit", 120, 90, 100, 30)
GUICtrlSetOnEvent($g_idExit, "OnExit")
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
GUISetState() ; display the GUI
While 1
Sleep(10)
WEnd
Exit
EndFunc ;==>_Main
Func PM11031()
$UserData = _InputBox("Enter Data")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("data 1 is: " & $UserData[0] & "data 2 is: " & $UserData[1] & "data 3 is: " & $UserData[2] & "data 4 is: " & $UserData[3] & ".")
Send("{ENTER}")
EndFunc ;==>PM11031
Func _InputBox($Title)
Dim $data[4]
Local $GUI2 = GUICreate($Title, 256, 509, 314, 374)
Local $Input1 = GUICtrlCreateInput("", 19, 40, 213, 21)
Local $Input2 = GUICtrlCreateInput("", 19, 102, 213, 21)
Local $Input3 = GUICtrlCreateInput("", 19, 164, 213, 21)
Local $Input4 = GUICtrlCreateInput("", 19, 228, 213, 21)
GUICtrlCreateLabel("Data1", 18, 18, 180, 17)
GUICtrlCreateLabel("Data2", 20, 80, 150, 17)
GUICtrlCreateLabel("Data3", 20, 142, 150, 17)
GUICtrlCreateLabel("Data4 ", 20, 204, 200, 17)
$Button1 = GUICtrlCreateButton("OK", 18, 458, 101, 29, $BS_DEFPUSHBUTTON)
$Button2 = GUICtrlCreateButton("Cancel", 126, 458, 101, 29, 0)
GUISetState(@SW_SHOW)
Opt("GUIOnEventMode", 0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
;~ Exit
;SetError(1)
ExitLoop
Case $Button1
$data[0] = GUICtrlRead($Input1)
$data[1] = GUICtrlRead($Input2)
$data[2] = GUICtrlRead($Input3)
$data[3] = GUICtrlRead($Input4)
ExitLoop
Case $Button2
;~ Exit
;SetError(1)
ExitLoop
EndSwitch
WEnd
Opt("GUIOnEventMode", 1)
GUIDelete($GUI2)
If Not @error Then Return $data
EndFunc ;==>_InputBox
Func OnExit()
Exit
EndFunc ;==>OnExit