Detecting User Cancellation?

Moderator: Kathy_9

Post Reply
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Detecting User Cancellation?

Post by migf1 »

Hey guys,

is it possible to detect when the user cancels the script, so we can do some cleanup work?

Maybe something like the API sending such info (maybe via a method) and giving us some time to cleanup before it actually cancels the script?
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Detecting User Cancellation?

Post by fs999 »

I asked that question some time ago : Interception of a cancelled interactive command.
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Detecting User Cancellation?

Post by migf1 »

Ah, sorry I missed it. Thanks for pointing it out!

PS. Seems we cannot, right? In that topic, Levi assumes the script keeps running and provides a couple of ways to detect if a layer has been changed (if I got it right) .
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
LeviFiction
Advisor
Posts: 5984
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, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Detecting User Cancellation?

Post by LeviFiction »

migf1 - Correct but I want to make sure I'm being clear. The topic linked was about canceling a single command, not canceling the entire script.

If a user runs a script and the script calls a command like "HSL" interactively, the user can either apply it or cancel the command. Once they've canceled the command PSP asks "do you want to stop running the whole script"? The user can then cancel the entire script, or continue to run the script.

If a user cancels the entire script, the script stops dead. No more execution period. None of the documentation provided by Corel suggests there is a Cleanup routine/callback that is called. It just stops running the script. So no clean-up is possible if they cancel the entire script.

If they don't cancel the script, the script continues to run whether you used that command or not.

In fs999's case they had a plugin, and they wanted to know if they could detect if the plugin was cancelled while the script still ran. So I gave a few possible options. They aren't great options but they are at least manageable.

However, many commands in PSP do return values depending on whether or not they were properly run. So the answer I gave fs999 for dealing with the result of canceling a plugin is not meant to be universal advice. See what the command you're running returns, If anything. If the command normally returns data (e.g GetMaterial) and it now returns "None" the command was cancelled. But if the command never returns data (e.g. ColorAdjustHSL) then you can't check if the command was canceled. Again as far as I know.
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Detecting User Cancellation?

Post by fs999 »

The idea of counting the colours before and after the command is very good !
Post Reply