13aal 13aal - 9 months ago 24
Ruby Question

Running keystrokes from program

I'm writing a program to automate an e-mail process and would like to know if there's a way to run keystrokes from within the program?

For example say I have this string:

str = "test"

And it gets copied to a file:

File.open('str.txt', 'w') { |s| s.puts(str }

And after that I want to use
on the file and copy the information, is this possible in a Ruby program, without the use of external gems?

Operating system: Windows 7

nwk nwk

If you can't install gems but can copy ClipText.exe to your current directory, do so then run this code in Ruby:

File.open('str.txt', 'w') { |s| s.puts(str }
`cliptext.exe from str.txt`

For a more rigorous way of executing commands on Windows see "How to execute Windows CLI commands in Ruby?".