Shell Calculator and Send Input
Process Management
The following Lua application will shell the standard Windows calculator and then send keys to it with appropriate pauses in between the key strokes to assure the UI can handle them.
Lua
-- Assume the calculator is in the path to run, give it enough
-- time to start, we'll give 1.25 seconds.
os.execute("calc.exe")
ui.Sleep(1250)
-- Send "2+2="
ui.SendKeys("2")
ui.Sleep(100)
ui.SendKeys("{+}")
ui.Sleep(100)
ui.SendKeys("2")
ui.Sleep(100)
ui.SendKeys("{=}")
-- Wait 1 second, then send ALT+F4 to close calc (assuming it still has the focus).
ui.Sleep(1000)
ui.SendKeys("%{F4}")