Created
September 21, 2018 05:18
-
-
Save Trevor-/f661c2daf339f8f4a6afe65e0877bdb5 to your computer and use it in GitHub Desktop.
This will run a remote script on PhotoShop on the Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://forums.adobe.com/message/10632458#10632458 | |
if (app.name !== 'Adobe Photoshop') { | |
alert('Crash,for Adobe Photoshop only!'); | |
} | |
var remoteCode = 'https://gist.githubusercontent.com/Trevor-/6a02d8cb49bbfeb9822f061dea300bc1/raw'; | |
// this function is nicked from // https: //forums.adobe.com/thread/2364797 | |
function getSystemCommandStdout(command) { | |
var stdout = ""; | |
var tempFile = new File(Folder.temp + "/temp.txt"); | |
app.system(command + " > " + tempFile.fsName); | |
if (tempFile.open("r")) { | |
stdout = tempFile.read(); | |
tempFile.close(); | |
tempFile.remove(); | |
} | |
return stdout; | |
} | |
var result = getSystemCommandStdout("curl 'remoteCode'".replace("remoteCode", remoteCode)); | |
// Set script args dosn't work on PS so just using setenv | |
$.setenv("envVar1", "Hello"); | |
// Set environmental vars | |
$.setenv("envVar2", "World"); | |
// Run the "remote" script | |
eval(result); | |
// Share functions and vars | |
blah(testVar, 'bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment