Thanks, but i still cant get it to work. the GUI still freezes after the first output from the a.exe program. here is the code:
`local ui = require "ui"
local sys = require "sys"
local Window = ui.Window("test", "fixed",0,0)
Window.bgcolor = "15790320"
Window.font = 'Segoe UI'
Window.fontsize = "9"
Window:center()
Window.x = Window.x - 256
Window.y = Window.y - 256
Window.width = 512
Window.height = 512
Window:show()
local console_output = ui.Edit(Window,"",5,25,507,364)
local console_input = ui.Entry(Window,"",5,394,412,25)
local console_input_send = ui.Button(Window,"SEND",422,393,85,27)
local start_button = ui.Button(Window,"Start",5,424,90,30)
local shutdown_button = ui.Button(Window,"Shutdown",100,424,90,30)
local mainpipe = nil
local function print_str(str)
console_output.text = console_output.text .. str
end
local main_printout_can = true
local function main_printout()
if mainpipe then
main_printout_can = false
async(function()
local output = mainpipe:read():wait()
print_str(tostring(output))
main_printout_can = true
end)
end
end
local function main_sendcmd(cmd)
print_str(cmd .. "\n")
if mainpipe then
mainpipe:write(cmd .. "\n")
end
end
console_input_send.onClick = function()
main_sendcmd(console_input.text)
console_input.text = ""
end
local function main_start()
if mainpipe then
print_str("[ERR] a.exe is already started!\n")
return false
end
mainpipe = sys.Pipe("a.exe")
if mainpipe then
print_str("a.exe is started!\n")
main_printout()
return true
end
print_str("[ERR] Can't start a.exe\n")
return false
end
local function main_shutdown()
if mainpipe then
print_str("Closing a.exe...\n")
mainpipe:close()
mainpipe = nil
return
end
print_str("[ERR] a.exe is already closed!\n")
end
start_button.onClick = main_start
shutdown_button.onClick = main_shutdown
async(function()
while Window.visible do
if main_printout_can then
main_printout()
end
ui.update()
end
end)`