15 - talking to applescript to get user input.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 27 行

RB
27
字号
require 'rubygems'require 'applescript'name = AppleScript.gets("What's your name?")AppleScript.puts("Thank you!")choice = AppleScript.choose("So which of these is your name?",                             ["Leonard", "Mike", "Lucas", name])if name == choice  AppleScript.say "You are right!"  picture = AppleScript.choose_file("Find a picture of yourself")  if File.exists?(picture)    AppleScript.say "Thanks, I will now post it on Flickr for you."    # Exercise for the reader: upload the file to Flickr  endelse  AppleScript.say "But you just said your name was #{name}!"end#---script = 'tell application "Finder" to display dialog "Hello World!" ' +         'buttons {"OK"}'AppleScript.execute(script)#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?