From: Ryan Mohr Date: 2010-06-17T07:34:43+09:00 Subject: Re: Simulating keystrokes for automated user input Brian Candler wrote > Otherwise, perhaps you can explain what you are trying to achieve? In addition to the CLI, I'm developing a simple gui interface. As the user interacts with the gui, commands are sent back to the CLI through a socket connection. At this point my CLI has nearly 100 commands and growing, so the easiest approach would be for the GUI to just send the text command desired and have it "typed" into the main app. If I go the internal API route (eg. no simulated typing), the command executes and the output is displayed, but now the old prompt is buried above the new output and the prior 'gets' request is still waiting for input. Since some of the commands have nested commands requesting input of their own, this stale 'gets' call is problematic. It's all pretty messy and probably hard to understand from my description. The addition of the gui was an afterthought so the CLI wasn't designed for this kind of use. The elegance of a simulated typing solution has pushed me towards using applescript to solve the issue (but even that has issues of its own such as the inability to send text to specific background windows). Thanks for all the help though. I'll keep hacking away at it. -- Posted via http://www.ruby-forum.com/.