Script advice - start script with getting Selection tool

Moderator: Kathy_9

Post Reply
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Script advice - start script with getting Selection tool

Post by JoeB »

This is something I don't seem to be able to do with script recording using PSP X7 Ultimate.

I often make a selection and then crop to that selection, usually using the Rectangle selection tool with no anti-alias, etc. I would like to have a script that I can bind to my toolbar (I know how to bind) that, when run, will select the Rectangle selection tool (from whatever tool I may have selected at the time), pause to let me make whatever size selection I want, and then, by hitting the button again, run the Crop to Selection part of the script.

And, if I had such a script kindly provided by someone, it might provide me with enough insight reading it that I might be able to use it as a template to also do other quick things that have to start with getting a tool then pausing while I do something then letting the script run again to complete some editing function.

If Corel creates a Scripting sub-forum to this forum I'd post such requests there, but it's here for now. :-)

Regards,

JoeB
Last edited by JoeB on Fri Jun 12, 2015 7:56 pm, edited 1 time in total.
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 advice - start script with getting Selection

Post by LeviFiction »

In this one particular case wouldn't it be easier to just put the rectangular selection tool and the crop to selection button on a toolbar next to each other? Would save time and being right next to each other loses no speed or time.

Pixelnook has a demonstration of use a Pause Script - http://pixelnook.home.comcast.net/~pixe ... ptDemo.htm

Here is my poor example of the script you're looking for. Used PixelNook's tutorial.
Attachments
SelectionCrop.zip
(2.32 KiB) Downloaded 291 times
https://levifiction.wordpress.com/
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Script advice - start script with getting Selection

Post by JoeB »

LeviFiction wrote:In this one particular case wouldn't it be easier to just put the rectangular selection tool and the crop to selection button on a toolbar next to each other? Would save time and being right next to each other loses no speed or time.

Pixelnook has a demonstration of use a Pause Script - http://pixelnook.home.comcast.net/~pixe ... ptDemo.htm

Here is my poor example of the script you're looking for. Used PixelNook's tutorial.
Thanks for your reply! Your suggestion is something I thought of but I always strive to minimize the number of buttons while at the same time maximizing efficiency - not always easy! :-) Your suggestion would mean having a button for the rectangle selection tool as well as the existing selections button with the existing options, as well as the crop button. A script button doing both chores means only one additional button without having a separate rectangle selection button - and I click on the same button to get both the selection and crop done which is just a tiny bit more efficient than clicking one button to do the selection and another one for the crop. But I do get your point for chores where a script just can't do the job.

And there is always the chance that having a script that does this chore will give me insight enough to be able to do something similar for other such chores, so in the end could save having even more redundant buttons when the tool or adjustment already exists in an existing multi-button.

I'm going to test out your script and will report back. And thanks for the PixelNook link. I had a dim memory from years that there was a script to show how to do a pause (and had used it back in the day) but had forgotten where it was, so will now be checking that out again. Thanks again!

Regards,

JoeB
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Script advice - start script with getting Selection

Post by JoeB »

Works like a charm Levi! I imagine I should be able to edit it so that it doesn't ask me if I want to continue with the next step, or would doing so prevent the ability to undo a step?

Regards,

JoeB
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 advice - start script with getting Selection

Post by LeviFiction »

Yes, you can remove that box if you want to. It won't break anything.

Here is the code you're looking for.

Code: Select all

if doStep > 0:
        result = App.Do(Environment, 'MsgBox', {
        'Buttons': App.Constants.MsgButtons.YesNo,
        'Icon': App.Constants.MsgIcons.Question,
        'Text': 'Continue with %s step %s?' % (scriptName, stepList[doStep][6:])
        })
        if result == 0:
            result = not App.Do(Environment, 'MsgBox', {
            'Buttons': App.Constants.MsgButtons.OKCancel,
            'Icon': App.Constants.MsgIcons.Stop,
            'Text': 'Stop all script steps?'
            })
            if result == 1:
                return
Just comment out that code or delete it. I prefer commenting because you may one day want to re-enable it. Who knows.
https://levifiction.wordpress.com/
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Script advice - start script with getting Selection

Post by JoeB »

Thanks! Didn't want to do anything that might break it.
Regards,

JoeB
Using PSP 2019 64bit
Post Reply