- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(AppleScript);
*目次 [#n4e303df]
#contents
*参考情報 [#f760a623]
-[[Google ChromeをAppleScriptで操作する - DiaryException:http://d.hatena.ne.jp/LaclefYoshi/20101024/1287887644]]
*Tips [#td8f4e18]
**ターミナルから実行する [#y31909ba]
-以下のコマンドで実行可能。[[AppleScript 2.1 Help: ターミナルのコマンドラインから AppleScript スクリプトを実行する:http://docs.info.apple.com/jarticle.html?path=AppleScript/2.1/jp/as164.html]]
osascript scriptname
*サンプル [#cb195c78]
** 最前面で選択されているテキストを取得する [#v9d20807]
#pre{{
set frontmostApp to path to frontmost application
tell application "Finder"
set appName to displayed name of frontmostApp
end tell
activate application appName
tell application "System Events"
tell application process appName
keystroke "c" using command down
end tell
end tell
tell application appName
set theText to the clipboard as string
end tell
}}
*トラブルシューティング [#of0f0f79]
**奇妙なEnd of Lineシンタックスエラーが発生する [#o5470284]
-以下のChromeのタイトルを取得する単純なAppleScriptが動かない。 [[Odd "End of Line" Syntax Error? | Apple Support Communities:https://discussions.apple.com/thread/5693069?tstart=0]]と同じような減少。
tell application "Google Chrome" to tell active tab of window 1
-原因はParallelsのChromeがMac側で共有されているせいだった(Windows側のChromeが参照されていた?)。Windowsの仮想マシン全てでアプリケーションの共有をオフにする。これでAlfredなどでParallels側のChromeがでてこなくなればOK。
-Chromeのプロパティを取得できるかどうか確かめてみたところまったくだめで気がついた。
#pre{{
tell application "Google Chrome"
get properties of window 1
end tell
}}
**Applescript “Expected end of line but found propertyのエラー [#s2110270]
-[[Applescript "Expected end of line but found property." error when using google chrome - Stack Overflow:http://stackoverflow.com/questions/22847583/applescript-expected-end-of-line-but-found-property-error-when-using-google-c]]にあるように、ParallelsのWindowsアプリの共有を有効化するとだめみたい。