Script question: Disable bound icon if no image is open

Corel Paint Shop Pro

Moderator: Kathy_9

Post Reply
photodrawken
Posts: 684
Joined: Wed Sep 26, 2012 8:40 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Hard_Drive_Capacity: 324Gb
Location: USA

Script question: Disable bound icon if no image is open

Post by photodrawken »

I've created a script and bound it to an icon, then added the icon to the standard toolbar.

Everything works, but the script will (correctly) give an error message if it's run when no image is open.

The bound icon on the toolbar is always enabled, even if no image is open. Is there a way to have the icon disabled (grayed out) if no image is open?
Ken
Yes, I think it can be eeeeeasily done...
Just take everything out on Highway 61.
Cassel
Posts: 1587
Joined: Fri Oct 29, 2010 6:49 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Corel programs: PSP 8 (JASC) to PSP 2023
Location: Canada
Contact:

Re: Script question: Disable bound icon if no image is open

Post by Cassel »

I am not aware of such feature, but if it is possible, i sure would LOVE to find out too!
Cassel
https://creationcassel.com/store
Specializing in PSP specific products: scripts and tubes

https://scrapbookcampus.com
for beginner and seasoned scrappers and designers and other PSP users
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Script question: Disable bound icon if no image is open

Post by LeviFiction »

No there isn't. They don't even have a command for checking for an image built into the language API. They originally made the PSPUtils script library to make up for things like that.

You know, of all of the things we asked for for scripting. Maybe this should be considered in the future. Make it part of the script properties 'RequiresDocument': 1 as well as other things like 'RequiresSelection', or 'Requiresvector' and so on. Really make it decently conditional. Even though most would only use the first one.

Time to bring this up at the other forum.
https://levifiction.wordpress.com/
photodrawken
Posts: 684
Joined: Wed Sep 26, 2012 8:40 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Hard_Drive_Capacity: 324Gb
Location: USA

Re: Script question: Disable bound icon if no image is open

Post by photodrawken »

LeviFiction wrote:No there isn't.
Ahh, too bad. Thanks for the info.
LeviFiction wrote:They don't even have a command for checking for an image built into the language API. They originally made the PSPUtils script library to make up for things like that.
Yes, I noticed the

Code: Select all

def Do(Environment):
    if PSPUtils.RequireADoc( Environment ) == App.Constants.Boolean.false:
        return
lines of code in one of the supplied scripts. Unfortunately, adding those lines prevents the first message box from appearing (before the script output window appears). That message box is important because it tells the user exactly why the script failed -- no active document.
LeviFiction wrote:You know, of all of the things we asked for for scripting. Maybe this should be considered in the future. Make it part of the script properties 'RequiresDocument': 1 as well as other things like 'RequiresSelection', or 'Requiresvector' and so on. Really make it decently conditional. Even though most would only use the first one.
Yes. For Photoshop Elements, Adobe uses a single line of commented code at the beginning of the script to tell the program whether or not to enable the script, depending on if a document needs to be opened or not. It's a pretty smooth system....

PSP has a distance of several light years to travel before it gets the good scripting capabilities offered by Adobe (with their Extend Script Toolkit), or even CorelDraw with its use of the VSTA editor (for .Net scripting). In each case, the object model has been exposed -- via an XML file in the case of Adobe, and via a .Net framework object model in the case of CorelDraw. Either way, it makes accessing the program's functions much more useful.
LeviFiction wrote:Time to bring this up at the other forum.
What forum is that?
Ken
Yes, I think it can be eeeeeasily done...
Just take everything out on Highway 61.
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Script question: Disable bound icon if no image is open

Post by LeviFiction »

Well, you can give a more detailed message box instead of only using return. Not that there's any real point in doing so.

I can't speak to Adobe or CorelDraw but accessing PSP's functions via object could easily be accomplished. We would just need someone to take the time to make that object library. Still waiting on Corel to update the scripting documentation though. And they really need to work on adding more functionality options. They've long let the options remain un-improved.

The CorelYourWay forum.
https://levifiction.wordpress.com/
Post Reply