2ちゃんねる スマホ用 ■掲示板に戻る■ 全部 1- 最新50    

■ このスレッドは過去ログ倉庫に格納されています

AppleScript アップルスクリプト 質問、発表 7

1 :名称未設定:2017/04/01(土) 12:42:51.78 ID:F8/5NUFI0.net
質問、発表どっちでもスレ。

■注意
安直なスクリプト作成依頼、丸投げ、「こういうの作ってください!」はお断り。
わからない点、エラーが解決できない点についてはスクリプト片を添えて質問すること。
OSバージョンも忘れずに。

■参考
AppleScript Language Guide
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/
TN2065: do shell script
https://developer.apple.com/library/mac/technotes/tn2065/
AppleScript: The Language of Automation
http://www.macosxautomation.com/applescript/
MacWiki - AppleScript
http://macwiki.osdn.jp/wiki/index.php/AppleScript
鳶嶋工房 / AppleScript
http://tonbi.jp/AppleScript/
AS Hole(AppleScriptの穴)
http://piyocast.com/as/
■過去スレ直近5つ
6 http://potato.2ch.net/test/read.cgi/mac/1387630245/
5 http://anago.2ch.net/test/read.cgi/mac/1330350325/
4 http://anago.2ch.net/test/read.cgi/mac/1256127156/
3 http://pc11.2ch.net/test/read.cgi/mac/1223026902/
2 http://pc11.2ch.net/test/read.cgi/mac/1197443062/

21 :名称未設定:2017/04/28(金) 23:08:06.28 ID:gZFbChtN0.net
前半の数行は、
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
じゃいかんの?
後半はよく知らないけど

22 :名称未設定:2017/04/28(金) 23:12:10.34 ID:gZFbChtN0.net
ゴミレスだった。。。
ごめんね

23 :名称未設定:2017/04/28(金) 23:12:52.64 ID:dTKzjSUR0.net
とりあえず同じことを簡単に書くならこう

tell application "System Preferences"
reveal anchor "Text" of pane id "com.apple.preference.keyboard"
activate
end tell

UI Scripting はスマートじゃないから別の方法がほしいってことだと思うけど
iCloud の絡みもあるしユーザ辞書のデータは直接いじらないほうがいい気がする

24 :名称未設定:2017/04/28(金) 23:42:24.35 ID:ioUFI/yc0.net
こんな感じでどう?

tell application "Finder"
open POSIX file "/System/Library/PreferencePanes/Keyboard.prefPane"
end tell
tell application "System Events"
tell process "System Preferences"
repeat
if exists tab group 1 of window 1 then exit repeat
delay 0.3
end repeat
tell tab group 1 of window 1
click radio button 2
click button 1 of group 1
set value of text field of UI element 2 of last row of table 1 of scroll area 1 to the clipboard
click text field of UI element 1 of last row of table 1 of scroll area 1
end tell
end tell
end tell

25 :名称未設定:2017/04/28(金) 23:44:51.44 ID:ioUFI/yc0.net
>>23
こんな書き方あったのか…

26 :名称未設定:2017/04/29(土) 12:12:09.72 ID:FcvMI78f0.net
>>21-24
ありがとうございます
俺環なのかもしれませんが、POSIXで指定したら環境設定が最前面に来ないし
応答が遅くなるので、前半はSpotlightのままにしました
あと、set valueでやると、入力は出来るんだけど単語登録されないという
不思議な事態になったので、repeatのところだけ書き加えて改変しました

tell application "System Events"
key code 49 using command down
key code 102
delay 0.5
keystroke "keyboard"
delay 0.5
key code 36
delay 0.5
tell process "System Preferences"
repeat
if exists tab group 1 of window 1 then exit repeat
delay 0.3
end repeat
tell tab group 1 of window "Keyboard"
click radio button 2
click button 1 of group 1
delay 0.3
keystroke tab
keystroke "v" using command down
keystroke tab using shift down
end tell
end tell
end tell

27 :名称未設定:2017/04/29(土) 13:42:30.99 ID:Ux9tvKvS0.net
>>26
前半は>>23のやり方がベストだろう。変なことする必要もないし行数も半分以下

28 :名称未設定:2017/04/29(土) 13:47:49.82 ID:FcvMI78f0.net
>>27
環境設定のウィンドウが最小化されてると動かないことないですか? 

29 :名称未設定:2017/04/29(土) 18:09:01.88 ID:FcvMI78f0.net
reopenつけたらいけました!!
ありがとうございます

30 :名称未設定:2017/04/30(日) 06:08:05.40 ID:1oYYm5910.net
こうか
こんな書き方あったんだな

tell application "System Preferences"
reveal anchor "Text" of pane id "com.apple.preference.keyboard"
activate
reopen
end tell

総レス数 1001
395 KB
新着レスの表示

掲示板に戻る 全部 前100 次100 最新50
read.cgi ver 2014.07.20.01.SC 2014/07/20 D ★