|
Revision 147, 1.7 kB
(checked in by cho45, 6 years ago)
|
|
javascript/pshell,
javascript/pshell/pshell,
javascript/pshell/shell.jsx,
javascript/pshell/README,
javascript/pshell/init.js:
Photoshop CS3 シェル。
|
| Line | |
|---|
| 1 | //#!open -a /Applications/Utilities/Adobe\ Utilities.localized/ExtendScript\ Toolkit\ 2/ExtendScript\ Toolkit\ 2.app |
|---|
| 2 | // vim:ft=javascript: |
|---|
| 3 | |
|---|
| 4 | #target bridge |
|---|
| 5 | |
|---|
| 6 | /* |
|---|
| 7 | @@@START_XML@@@ |
|---|
| 8 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| 9 | <ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en_US"> |
|---|
| 10 | <dc:title>CS3 Shell</dc:title> |
|---|
| 11 | <dc:description>This script is for CS3 interactive shell.</dc:description> |
|---|
| 12 | </ScriptInfo> |
|---|
| 13 | <ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ja_JP"> |
|---|
| 14 | <dc:title>CS3 Shell</dc:title> |
|---|
| 15 | <dc:description>このスクリプトは、インタラクティブシェル用のものです。 |
|---|
| 16 | 外部スクリプトとあわせて使用します。</dc:description> |
|---|
| 17 | </ScriptInfo> |
|---|
| 18 | @@@END_XML@@@ |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | global = this; |
|---|
| 22 | |
|---|
| 23 | BridgeTalk.onReceive = function (bt) { |
|---|
| 24 | return (function () { return eval(bt.body) }).apply(global); |
|---|
| 25 | }; |
|---|
| 26 | |
|---|
| 27 | try { |
|---|
| 28 | |
|---|
| 29 | if (BridgeTalk.appName == "bridge") { |
|---|
| 30 | |
|---|
| 31 | var fileIn = new File("/tmp/cs3-command-in"); |
|---|
| 32 | var fileOut = new File("/tmp/cs3-command-out"); |
|---|
| 33 | |
|---|
| 34 | var target = "photoshop"; |
|---|
| 35 | |
|---|
| 36 | function response(res) { |
|---|
| 37 | if (res === "") res = '""'; |
|---|
| 38 | fileOut.open("w"); |
|---|
| 39 | fileOut.write(res); |
|---|
| 40 | fileOut.close(); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | function request() { |
|---|
| 44 | fileIn.open("r"); |
|---|
| 45 | var ret = fileIn.read(); |
|---|
| 46 | fileIn.close(); |
|---|
| 47 | fileIn.open("w"); |
|---|
| 48 | fileIn.close(); |
|---|
| 49 | return ret; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | function evaluate () { |
|---|
| 53 | try { |
|---|
| 54 | if (code = request()) { |
|---|
| 55 | var targetApp = BridgeTalk.getSpecifier(target); |
|---|
| 56 | var bt = new BridgeTalk(); |
|---|
| 57 | bt.target = targetApp; |
|---|
| 58 | // bt.headers.Command = "Eval"; |
|---|
| 59 | bt.body = code; |
|---|
| 60 | bt.onResult = function (e) { |
|---|
| 61 | response(e.body); |
|---|
| 62 | }; |
|---|
| 63 | bt.onError = function (e) { |
|---|
| 64 | response(e.body); |
|---|
| 65 | }; |
|---|
| 66 | bt.send(); |
|---|
| 67 | } |
|---|
| 68 | } catch (e) { |
|---|
| 69 | response(e); |
|---|
| 70 | } |
|---|
| 71 | app.scheduleTask("evaluate();", 10, false); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | evaluate(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | } catch (e) { |
|---|
| 78 | alert(e); |
|---|
| 79 | } |
|---|
| 80 | |
|---|