Copy link to clipboard
Copied
I have a plugin (.dll) written in C++ that I want to create a custom panel for, so a few questions:
Is this possible?
If so, could you point me in the direction of what I have to use, I understand that I can use ActiveXObject for web to call native dlls in Js. Would this work for Photoshop?
Yes it has some example calls, also see Action Manager (Script Listener) code converter script! for a modified cpp that gives access to the system command and clipboard functions.
Copy link to clipboard
Copied
Your .dll (with different name in extension) should have JSX interface. So you can use classic Action Manager code for you own plugin.
Copy link to clipboard
Copied
There is an example of a dll in the Bridge SDK Bridge Developer Center
It also shows how to interface with JSX.
Copy link to clipboard
Copied
Your .dll (with different name in extension) should have JSX interface. So you can use classic Action Manager code for you own plugin.
Does the classic Action Manager use the Bridge?
There is an example of a dll in the Bridge SDK Bridge Developer Center
It also shows how to interface with JSX.
Thanks guys, after talking to the artists they entirely want to stay away from the Bridge at all costs. Half of them already uninstalled it from their machines. Do you have any other suggestions?
Copy link to clipboard
Copied
Although the example is in the Bridge SDK the dll can be used in Photoshop see "BasicExternalObject" example.
In fact I use that example with modifications for use in Photoshop.
Copy link to clipboard
Copied
Thank you Merlin, quick question about the 'BasicExternalObject' will this contain UI examples or just the connection to the API calls through Js?
Copy link to clipboard
Copied
You can create GUI in C++ or in JSX
Anyway in C++ it would be better.
Copy link to clipboard
Copied
I've currently created the GUI from a C++ resource file but the only way to access it is through File->Automation->MyPlugin, I need a better way to do this with a custom panel icon or something else.
Copy link to clipboard
Copied
Yes it has some example calls, also see Action Manager (Script Listener) code converter script! for a modified cpp that gives access to the system command and clipboard functions.
Copy link to clipboard
Copied
Hey Super, sorry to be a nuisance I'm currently looking at the code from the source you supplied 'AM Code Replacement.jsx' and it seems it's just opening the written file and parsing out the text, I don't see where exactly it's calling any API functions (Js is not my language so please tell me if I'm missing something):
// https://forums.adobe.com/thread/2249343 / CS5.1 / Kukurykus / 15.12.16
// it changes ActionManager code to be much more readeable and neat
function rw(v1, v2, v3) {v2.open(v1), v1 < 'w' ? v3 = v2.read() : v2.write(v3), v2.close(); return v3}
(win = new Window('palette' )).add('statictext {text: "Please wait to end of this process..."}'), win.show()
c = rw('r', File('~/Desktop/ScriptingListenerJS.log')).replace(/(.*\n(.*\n)+|^)([\/ =]+\n)+(.*(\n.*)+)\n\n/, '$4')
r = {a: ["'(^|;\\n) *(var )?'", '\r'], b: ["'\\\\( '", '('], c: ["' \\)'", ')'], d: ["'\"'", '\''], e: ["'ref'", 'REF'],
f: ["'desc'", 'DSC'], g: ["'list'", 'LST'], h: ["'string'", 's'], i: ["'char'", 'c'], j: ["'IDToTypeID'", 'TT']}
eval(l ="for(i in r) c = c.replace(eval('RegExp(' + r[0] + ',\"g\")'), r[1])");
for(i = 0, ARR = eval(arr = '[r.e[1], r.f[1], r.g[1]]'); i < (ARR).length; i++) {
if (!i) arr = eval(arr.replace(/1/g, '0')); arr = ARR.toLowerCase(), n = 1
while(num = c.match(RegExp(ARR + '\\d+'))) c = c.replace(RegExp(num, 'g'), eval(tLC = "arr") + n), n++
if (num && !RegExp((onl = eval(tLC)) + 2).test(c)) c = c.replace(RegExp(onl + 1, 'g'), onl)
}
while(lne = c.match(/(\w+) = ((s|c)TT\('#?[\w ]*'\))/)) {
if ((Ps = /P.*p/.test(app.name)) && lne[3] == 'c') {
l2 = lne[2], lne[2] = "sTT('" + eval(lne[2].replace(/cTT(.*)/, 'typeIDToStringID(charIDToTypeID$1)')) + "')"
if (/''/.test(lne[2])) lne[2] = l2
}
eval((slh = "c = c.replace(RegExp(lne[0].replace(/(?=\\()/, '\\\\').replace(/(?=\\))/, '\\\\')), '')")
+ ".replace(RegExp(lne[1] + '(?=,|\\\\))' + '\\\\b'), lne[2])")
}
for(i = 0; i < arr.length; i++) {
while(lne = c.match(RegExp('(\\b' + arr +'(\\d*))' + '.*?\)'))) {
eval(slh + ".replace(RegExp('\\\\b' + lne[1] + '(?!\\\\d)'), '(' + lne[0] + ')')\
.replace(RegExp('\\\\b' + lne[1] + '(?!\\\\d)', 'g'), ARR + lne[2])")
}
}
for(i = 0; i < ARR.length; i++) {
c = c.replace(RegExp(' \\((' + String(ARR).replace(/,/g, "|") + ')\\D[= ]+(.*?(\)))\\3', 'g'), ' $2')
.replace(RegExp(ARR, 'g'), arr)
}
r = {a: ["'((\\\\.0+\\\\b|(\\\\.[0-9]{0,5}?)0+))(?=\\\\))'", '$3'], b: ["'(\\\\d)undefined'", '$1'],
c: ["'\\\\r\\\\s+'", '\n'], d: ["'\\)(\\n|\\r)\\\\('", ');\n('], e: ["'\\r|\\n'", '\n\t']}
c = 'function cTT(v) {return charIDToTypeID(v)}; function sTT(v) {return stringIDToTypeID(v)}\
\nfunction someName() {' + eval(l) + '\n}\nsomeName()', rw('w', File('~/Desktop/Code.txt'), c)
s = [$.screens[0].right - 880, (l = c.match(/\n/g).length + 1) < 69 ? l * (16.14 - (l - 5) * (.091 / 67)) : $.screens[0].bottom - 100]
ans = (win = new Window('dialog' )).add('edittext {preferredSize:'+ uneval(s)+', properties: {multiline: true}}')
ans.text = c, ans.active = true, win.add ("button", [0,0,28,19], "OK", {name:'close'}); if (!/P.*p/.test(app.name)) win.show()
// if (Ps) File(File($.fileName).path + '/AM.exe').execute(); win.show() // deprecated since for Windows only
if (/P.*p/.test(app.name)) app.system((/Windows/.test($.os) ? 'clip' : 'pbcopy') + ' < %HOMEPATH%/desktop/Code.txt')
Copy link to clipboard
Copied
As an example, compile the code (64bit) place the dll in the presets/scripts folder.
Then you can run this script in ExtendScript Toolkit
#target Photoshop
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize('$$$/ScriptingSupport/InstalledScripts=Presets/Scripts'));
var libPath =SCRIPTS_FOLDER + "/BasicExternalObject.dll";
var psEX = new ExternalObject("lib:" + libPath);
$.writeln(psEX.getClipboard());
$.writeln("-----------------------------");
//Put data on clipboard
psEX.setClipboard("This is put on the clipboard!");
//Get data from clipboard
$.writeln(psEX.getClipboard());
//Clear clipboard
psEX.clearClipboard();
var task = psEX.systemCmd('tasklist').match(/Photoshop.exe/im);
if(task == null){
$.writeln("Photoshop is not running");
}else{
$.writeln("Photoshop is running");
}
This is the basics of calling and retrieving data.
By the way there is a compiled dll here. http://wikisend.com/download/563538