Instructions:
- there are 2 files in the .rar file: AM Code Replacement and AC.exe (plus just in case AC.ahk)
- put both files in the same folder, then launch Photoshop
- if you don't have any code recorded to ScriptListener.log on your Desktop, do anything can be written to
- run the script:
* in PS it uses AHK script to hihglight & copy code and press enter, so you can simply press ctrl v in any editor you use
* in Extendscript the text will be highlighted by a script but, AHK script won't be ran, so you must copy a code yourself
I created it in Photoshop 5.1 with Windows 10, but I think it should work with PS 6 and probably next versions too
I tested it so far with for ex. opening new document, creating text in text layer, adding effects, and Puppet Warp
If it won't work for you or if converted result ran again for ex. from Extendscript doesn't give the same result as PS let me know.
Possibly later I'll describe line after line what it exactly do before it reach final result.
An update to instructions:
First update was for suggestion of Jaroslav Bereza, who wanted chars were displayed as strings.
Now the second update is for Javier Archoe. Noone needs anymore be Windows user to copy content of result to clipboard automaticly by script. I was using AHK script to this, but now it's possible it will happen irrespectively beeing on Mac or Pc.
Another part of this update was fixing empty strings which were effect of most filters conversion from chars to strings. I simply restricted such changes if a script detected a result will be an empty string. So what can't be converted it will stay as original char. For example I checked all Artistic, Blur filters and single Liquify. I found these charIDToTypeID "Avrg", "BeIn", "BeNu", "BeS6", "BkDi", "BkDp", "BkDs", "BkIb", "BkIc", "BkIr", "BkIs", "BkNa", "BkNm", "BkNt", "BkSb", "BkSt", "Bokh", "BtDi", "BtIs", "BtNt", "GEfc", "GEfk", "GEft", "LqFy", "VnPt" dont' have equivalent stringIDToTypeID. There are probably more of them but fortunately that wasn't needed search for them all to make script working properly if it finds their "buddies".
I found also that script brekes with Lens Correction in filters section. I'm not sure I want to fix it. It seems a code partially looked like taken from XML, while I didn't designed a script to find its characters. It's only single case so probably I won't use even try...catch statement to fix it.
Code: Select all
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[i][0] + ',\"g\")'), r[i][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[i] = ARR[i].toLowerCase(), n = 1
while(num = c.match(RegExp(ARR[i] + '\\d+'))) c = c.replace(RegExp(num, 'g'), eval(tLC = "arr[i]") + 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[i] +'(\\d*))' + '.*?\)'))) {
eval(slh + ".replace(RegExp('\\\\b' + lne[1] + '(?!\\\\d)'), '(' + lne[0] + ')')\
.replace(RegExp('\\\\b' + lne[1] + '(?!\\\\d)', 'g'), ARR[i] + lne[2])")
}
}
for(i = 0; i < ARR.length; i++) {
c = c.replace(RegExp(' \\((' + String(ARR).replace(/,/g, "|") + ')\\D[= ]+(.*?(\)))\\3', 'g'), ' $2')
.replace(RegExp(ARR[i], 'g'), arr[i])
}
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')
(+24 times before replacement)