解决方法
对于Mac:
@H_404_8@gem install rb-appscript
然后你可以用这样的脚本测试它:
@H_404_8@require "rubygems" require "appscript" include Appscript app("TextEdit").activate app("System Events").keystroke("Look Ma,keystrokes!")对于Windows :(未经测试,borrowed from this thread)
@H_404_8@require "win32ole" wsh = WIN32OLE.new("WScript.Shell") wsh.Run("Notepad.exe") while not wsh.AppActivate("Notepad") sleep .1 end wsh.SendKeys("Look Ma,keystrokes!")