Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Event Script manager - Closed document - event

Engaged ,
Apr 14, 2016 Apr 14, 2016

Hi EveryOne!

I need call one script when active document close. I add that script into Event Script manager with Closed document event.

The Script will working after document close. I just want run the script before close document event.

Please suggest me any other alternate solution or advice.

-yajiv




TOPICS
Actions and scripting
894
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 14, 2016 Apr 14, 2016

I would recommend setting up the Script to do whatever and then close the active image, then assigning it the default close-shortcut (cmd-W on a Mac).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 14, 2016 Apr 14, 2016

Another option would be to open the document again apply your script and close the document.

If you don't know what the last document was you could try:-

app.open(app.recentFiles[0]);

For some reason the Recent File list is not always updated maybe smeone might know why?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2016 Apr 15, 2016

As there are more than one way to close an open document your approach seems much more reliable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 15, 2016 Apr 15, 2016

Hi Chris and SuperMerlin,

Thanks for the reply. Its a good approach. unfortunate its not working properly for huge files size.

Its take too much time to open and execute the script. Is it possible to create "BeforeClose" user event type in Photoshop?

-yajiv

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 16, 2016 Apr 16, 2016

Sorry not that I know of, the close event is after it has occured.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 18, 2016 Apr 18, 2016

Sorry, I can't help.

I create a listener for many things, like a listener for color samplers creation.

The idea of the listener is to perform something immediately after it has been listened/triggered.

But using the 'close' activeDocument listener, it means that it will run when it was just closed = you cannot do anything to something that doesn't exist anymore.

But I agree that Adobe should do an exception in this special event, because if you want to ensure that a team doesn't close anything before doing something, it should have this option to run something before.

Here is the code I use to create that listener:

// close activeDocument listener

if (BridgeTalk.appName == "photoshop"){

    var myCloseDocScript = new File(Folder.desktop +"/myCloseDocScript.jsx");

    try {

        if (File(myCloseDocScript).exists) {

            app.notifiers.add("Cls ", myCloseDocScript);

        }

    }catch(e){}

}

Pedro Marques - Shaping the next era of e-commerce, from polished product images to seamless workflows to AI-generated content.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2016 Apr 18, 2016
LATEST

I do not use the bridge most of the time. I use windows and always have the scriptlistener installed in all versions of Photoshop.  I control what the scriptlisenter can record, extract what I need to extract and clear the scriptlistener javascript  log with a DOS bat file I run in a small window when I need some action manager script code.

Capture.jpg

@Echo Off

:loop

CLS

rem Display Log File Size

Dir "%USERPROFILE%\Desktop\ScriptingListenerJS.log" /T:W /4 | find "%ScriptingListenerJS.log"

rem Display Log Attributes  R read only Locked no R log is Unlocked

Attrib "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

Rem If timeout is use the above display lines will refresh over time else you need to use enter or number

CHOICE /C 123456 /N /T 300 /D 6 /M "Enter:1 to Lock, 2 to Unlock, 3 to Edit, 4 to Clear, 5 To Exit :"
Echo %ERRORLEVEL%
if %ERRORLEVEL%==6 goto timeout
if %ERRORLEVEL%==1 goto one
if %ERRORLEVEL%==2 goto two
if %ERRORLEVEL%==3 goto three
if %ERRORLEVEL%==4 goto four
if %ERRORLEVEL%==5 goto five
goto loop

:timeout

goto loop

:one

Attrib +R "%USERPROFILE%\Desktop\ScriptingListenerJS.log"
goto loop

:two

Attrib -R "%USERPROFILE%\Desktop\ScriptingListenerJS.log"
goto loop

:three

        Rem inline command use CMD independate command use start

CMD /C notepad "%USERPROFILE%\Desktop\ScriptingListenerJS.log"
remStart notepad "%USERPROFILE%\Desktop\ScriptingListenerJS.log"
goto loop

:four

Rem If the script log file is unlocked not read only  this echo will clear it

Echo. > "%USERPROFILE%\Desktop\ScriptingListenerJS.log"
goto loop

:five

EXIT
JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines