OSX Mavericksになってからなのか、Charles.appを立ち上げるたびに次のようなファイヤウォールの確認ダイアログが出るようになった。
AppleScript等でCharlesでのログ取りなど自動化をするにあたって、許可ボタンを自動的に押す必要があったので調べた。次のようなAppleScriptを書くと、ダイアログ内のテキストに「Charles.app」があったときだけ、許可ボタンを押すことが出来る。
具体的には、このダイアログはUserNotificationCenterというプロセスが表示しているようなので、そのプロセスに対してAppleScriptを実行している。
tell application "System Events"
-- ダイアログはUserNotificationCenterプロセスが表示しているので、まずはUserNotificationCenterプロセスの有無を確認
if "UserNotificationCenter" is in (get name of processes whose background only is true) then
tell process "UserNotificationCenter"
tell window 1
-- first static textは『アプリケーション"Charles.app"へのネットワーク……』という文字列を保持している
if value of first static text contains "Charles.app" then
click button "許可"
end if
end tell
end tell
end if
end tell
実装に当たって、以下のサイトを参考にした。