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

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

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

1 :名称未設定:2013/12/21(土) 21:50:45.07 ID:1PJJFexL0.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.sourceforge.jp/wiki/index.php/AppleScript
鳶嶋工房 / AppleScript
http://tonbi.jp/AppleScript/
AS Hole(AppleScriptの穴)
http://piyocast.com/as/
■過去スレ
1 http://pc11.2ch.net/test/read.cgi/mac/1174045850/
2 http://pc11.2ch.net/test/read.cgi/mac/1197443062/
3 http://pc11.2ch.net/test/read.cgi/mac/1223026902/
4 http://anago.2ch.net/test/read.cgi/mac/1256127156/
5 http://anago.2ch.net/test/read.cgi/mac/1330350325/

51 :名称未設定:2014/01/12(日) 22:26:26.36 ID:4upz722c0.net
行間を自動にてつめるスクリプトですが改良の余地がまだたくさんあるようです。
個人的にはこのスクリプトで自分が自分が目指していたのができとても喜んでいます。
下記に教えてくださった皆様のscriptを元に利用しているapplescriptです。
tell application "Adobe Illustrator"
tell document 1 -- ← every document にすると全体のテキストにかかるようであえてDocument1にします
--set defLeading to leading of character 1 of text frame 1
set defLeading to "24" -- ←本文の行間を固定しています
repeat with tFrame in every text frame
if kind of tFrame is {area text} then
if my overflow(tFrame) then
--display dialog "オーバーフロー:" & contents of tFrame
tell text frame 6
tell every line
repeat with i from defLeading to 0 by -1
set auto leading of lines to false
set leading of lines to i
if not my overflow(tFrame) then
exit repeat
end if
end repeat
end tell
end tell
end if
end if
end repeat
end tell
end tell

52 :名称未設定:2014/01/12(日) 22:27:20.26 ID:4upz722c0.net
たけうちとおるさんのハンドラをそのまま利用しています。
on overflow(tFrame)
set OriginalDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ""
tell application "Adobe Illustrator"
set myLastP to (contents of every paragraph of tFrame) as string
set myLastL to (contents of every line of tFrame) as string
set AppleScript's text item delimiters to OriginalDelimiters
if myLastP is not myLastL then
set AppleScript's text item delimiters to OriginalDelimiters
return true
else
set AppleScript's text item delimiters to OriginalDelimiters
return false
end if
end tell
end overflow

53 :名称未設定:2014/01/13(月) 03:11:37.98 ID:Sx62P48w0.net
do shell scriptを何度も繰り返しているのだけど、shellコマンドを入力する度に別のターミナルが開いてしまう。

tell application "Terminal"
do script with command "hoge"
do script with command "hoge2"
end tell

hogeとhoge2のコマンドを一つのターミナルウィンドウで処理させる事ってできますか?

54 :名称未設定:2014/01/13(月) 03:29:47.81 ID:XwnsQAAS0.net
コピペで動くんじゃないか

55 :名称未設定:2014/01/13(月) 04:10:03.05 ID:VPcx8yeO0.net
>>53
--ただ続けて実行したいだけなら
tell application "Terminal"
do script "hoge; hoge2"
end tell

--do scriptの戻りが実行されたtabなのでそれを使うパターン
tell application "Terminal"
do script "hoge"
do script "hoge2" in result
end tell

とりあえずdo shell scriptとTerminalのdo scriptが別物ってのは覚えとけ
ちなみに前者はdo shell scriptでも使える方法

56 :名称未設定:2014/01/13(月) 08:43:43.11 ID:Wpl4bEnlP.net
>>53
どういう理屈でアプリケーションを操作する仕組みか考えるといい。
Terminalはshellコマンドを実行するアプリではなく、PCをターミナルウインドウで
操作するアプリ。だからillustratorでパスとかオブジェクトを操作するのと同様、
操作する対象を「tell」などで明確にして実行することが大切。
その例だとアプリ本体に実行を指示しているだけなのでそんな結果になる。
過去にもその話、あったよ。

57 :名称未設定:2014/01/14(火) 16:18:00.69 ID:VipRDOQb0.net
Illustratorのテキスト書体変更でエラーがでました。
どなたかご教授ください。

tell application "Adobe Illustrator"
tell document 1
tell text frame 1
set properties of every paragraph of text frame 1 in document 1 to {text font:"Osaka"}
end tell
end tell
end tell

58 :名称未設定:2014/01/14(火) 21:10:07.61 ID:ZXykgTnJ0.net
>>57
ここで散々質問してきた人?
だとしたら成長の跡が見られない。
tellとはなんぞやからやり直した方が良い。

59 :名称未設定:2014/01/14(火) 22:03:45.56 ID:VipRDOQb0.net
>58
これでいいの?
set setStr to "サンプルテキスト"
set X to 10
set Y to 10
set setStr to setStr as string
set X to X as real
set Y to Y as real
set pt to 2.83
set X to X * pt
set Y to Y * pt
tell application "Adobe Illustrator"
set placedRef to make new text frame in document 1 with properties {contents:setStr, position:{X, Y}}
set properties of every paragraph of text frame 1 in document 1 to {size:8.5, fill color:{class:CMYK color info, black:100, cyan:0, magenta:0, yellow:0}, text font:"ShinGo-Bold-83pv-RKSJ-H"}
end tell

60 :名称未設定:2014/01/14(火) 22:57:38.60 ID:VipRDOQb0.net
>58
それともこれかな?
tell application "Adobe Illustrator"
set docRef to make new document with properties {color space:CMYK}
set romanText to "日本語書体変換"
set newText to romanText
set textRef to make new text frame in docRef with properties {position:{100, 200}, contents:newText}
set charStyle to make new character style in docRef with properties {name:"ヒラギノ明朝 Pro-W3"}
set kerning method of charStyle to metricsromanonly
set properties of every paragraph of text frame 1 in document 1 to {size:48}
set cmykColor to {cyan:50, magenta:20, yellow:10, black:5}
set fill color of charStyle to cmykColor
apply character style charStyle to text of textRef
end tell

総レス数 1008
389 KB
新着レスの表示

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