Scripted Undo's not happening

Moderator: Kathy_9

Post Reply
Dave_SMR
Posts: 8
Joined: Fri Jul 29, 2016 10:08 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: FOXCONN A76ML-K 30 1.0
processor: Athlon II X4 640
ram: 8GB
Video Card: ATI Radeon 3000 Graphics
Hard_Drive_Capacity: 250GB
Monitor/Display Make & Model: Hanns.G HL225D x 2
Corel programs: PSP X7 / VS X8

Scripted Undo's not happening

Post by Dave_SMR »

I'm struggling to get my script to undo previous actions during a batch process. I'm trying to save multiple resizes of a single image however I can't seem to undo the previous resize which is causing serious degradation in the each subsequent image's quality.

I've tried using directly after the resize (before I even save it) and it gets ignored.

Code: Select all

App.Do(Environment, 'UndoLastCmd')
I've also tried this command, which registers as an action in the script output window but has no effect.

Code: Select all

App.Do(Environment, 'UndoToHere', {
            'CmdIndicies': {
                'Index': 1
            }
        })
I've made sure that the optimised script undo block is not present also. Can anyone give me some advice on what I'm doing wrong?
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: Scripted Undo's not happening

Post by LeviFiction »

Well that's interesting. There seems to be something inside PSP that needs to get tripped or set but I don't know what it is. And that's probably a wrong assumption.

So I went through like six different scripts with various combinations of commands to come up with the following oddity.

If I have a script and it uses Undo, it'll fail every time no matter how many commands I have. And it doesn't seem limited to specific commands. However, if I make a selection before I run the script, the script executes perfectly and will continue to execute perfectly every time after that. It's like it requires an initial edit outside of a script for UndoLastCmd to work.

My first solution is to just hit CTRL + D before running your script. Ctrl + D does nothing since there are no active selections, and the script runs just fine after that.

If you want a scripting only option, that's where it gets annoying and ugly.

For a pure scripting solution you need a second script. This script will do two things. 1) Runs "SelectNone" and 2) Runs "RunScript" on the script you wanted to run.

Here is a quick video showing what I mean: https://drive.google.com/a/trinitybible ... JzRUk/view
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: Scripted Undo's not happening

Post by JoeB »

LeviFiction wrote:For a pure scripting solution you need a second script. This script will do two things. 1) Runs "SelectNone" and 2) Runs "RunScript" on the script you wanted to run.
Maybe I'm misunderstanding something, but can't the two scripts be combined into one script so that this "trigger" (if you will) of SelectNone runs and then the main script runs?
Regards,

JoeB
Using PSP 2019 64bit
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: Scripted Undo's not happening

Post by LeviFiction »

Nope. It's not "SelectNone" itself that's the trigger. It's how PSP interprets the two commands. It's really convoluted and ridiculous.

If all I had to do was add "SelectNone" to the beginning of the original script I would have. In fact, that was one of my first tests. The Undo command still failed to execute. The only way I could get it to work was to create a script that first performed SelectNone as an initial command then ran the script I wanted via "ScriptRun." As another fun side note, if I used "RunSelectedScript" instead of "ScriptRun" this method failed to execute the Undo command.

So the only method I was able to get to work was "SelectNone" followed by "RunScript."

Others may find it works differently for them. For all I know this is one of those very very screwy bugs in PSP that's never fixed the same way twice.
https://levifiction.wordpress.com/
Dave_SMR
Posts: 8
Joined: Fri Jul 29, 2016 10:08 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: FOXCONN A76ML-K 30 1.0
processor: Athlon II X4 640
ram: 8GB
Video Card: ATI Radeon 3000 Graphics
Hard_Drive_Capacity: 250GB
Monitor/Display Make & Model: Hanns.G HL225D x 2
Corel programs: PSP X7 / VS X8

Re: Scripted Undo's not happening

Post by Dave_SMR »

Thank you! I would never have thought to attempt any of those steps.

I've got the script working as desired.
Post Reply