×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Corel Paint Shop Pro Scripting Issue

Corel Paint Shop Pro Scripting Issue

Corel Paint Shop Pro Scripting Issue

(OP)
I ran into a problem the other day while running a custom Python script in Corels' Paint Shop Pro Photo X2.  The script was created using the 'Record' option under the File|Script menu.  I found that when I ran the script as a Batch Process it would randomly fail on certain png files.  The script would generate the following error but never on the same file twice:

Error Text:    The attempted operation is not valid in the current program state.

When I searched Tek Tips I found this thread:

http://www.tek-tips.com/viewthread.cfm?qid=1410589&page=5#post

This thread accurately descries the problem, but it unfortunately did not provide a solution.  Here is the fix:

The script appears to be running too fast.  I have noticed this only in scripts that are running as a Batch Process and only when the script tries to SAVE the file after it makes its modifications.

In order for the script to run properly you must pause the script at some point to give the software a chance to catch up.  You can do this simply by adding a few lines to the script that will cause the script to pause for a second or two.

First locate your script file.  The easiest way to this across all windows platforms is to just search for it.  The file name is YourScriptName.PspScript.  For example my script was called AutoCrop  so the filename for the script is AutoCrop.PspScript.  Once you have located the file, open it with notepad.

At the very top of your script, add this line:

   

CODE

import time


It is important that this is the first line in the script.

Now, at any point in the script add this line:

   

CODE

time.sleep(1)

I recommend putting this line at the very bottom of the script so that it is the last line in the file.  All this does is tells the script to pause for 1 second before it ends.  If you wish, you could change the 1 to another number to increase the amount of seconds the script pauses.  This will give PaintShopPro enough time to finish what ever it needs to do before the script runs again on another file as part of the Batch process.

Save your script and give it a try! The only drawback of course is that your script will now run more slowly, but hey, at least it will work!

Hope this helps someone....





 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close