I’d like to call SharpCap.RunRefocus() periodically from a script, but it appears that this function requires a successful focusing scan to have been run first. If no previous focusing scan exists, the call fails with an error message saying that a focusing scan must be performed first.
Is there any scripting/API-accessible interface or property that can be used to check whether a valid previous focusing scan exists before calling SharpCap.RunRefocus()?
Question about SharpCap.RunRefocus
- admin
- Site Admin
- Posts: 17342
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Question about SharpCap.RunRefocus
Hi,
not directly, but you can take advantage of the sequencer equivalent 'REFOCUS' step, which fails without a message box if there is no data. From python, you can use this as follows
By putting some logic in the progress event handling, you can work out if the refocus failed due to no data or some other reason, or if it ran OK.
cheers,
Robin
not directly, but you can take advantage of the sequencer equivalent 'REFOCUS' step, which fails without a message box if there is no data. From python, you can use this as follows
Code: Select all
>>> def Progress(sender, args):
... print(args.EventData)
...
>>> SharpCap.Sequencer.Progress += Progress
>>> SharpCap.Sequencer.RunSequence("REFOCUS")
Starting :
Starting : Refocus using the same settings as the most recently used autofocus run
Error : 'No previous autofocus information stored, cannot refocus' while running step Refocus using the same settings as the most recently used autofocus run
Info : 'No previous autofocus information stored, cannot refocus' while running step
End : Sequence halted due to error.
>>> SharpCap.Sequencer.Progress -= Progress
Finished
cheers,
Robin
Re: Question about SharpCap.RunRefocus
Thanks, Robin! Very fast reply as usual, and very helpful.
I’ll give the sequencer `REFOCUS` step approach a try. That should be enough for my current use case, especially if it fails cleanly without showing a message box when no previous autofocus data is available.
If at some point you add a scripting/API method to query the most recent autofocus/refocus state or results directly, I’d be very interested to know.
Regards,
Leo
I’ll give the sequencer `REFOCUS` step approach a try. That should be enough for my current use case, especially if it fails cleanly without showing a message box when no previous autofocus data is available.
If at some point you add a scripting/API method to query the most recent autofocus/refocus state or results directly, I’d be very interested to know.
Regards,
Leo
Re: Question about SharpCap.RunRefocus
Will the messages captured by Progress event handler be always in plain English, or will they be different for localized language version of SharpCap?
Thanks,
Leo
Thanks,
Leo
admin wrote: Sat Jun 13, 2026 1:03 pm Hi,
not directly, but you can take advantage of the sequencer equivalent 'REFOCUS' step, which fails without a message box if there is no data. From python, you can use this as follows
By putting some logic in the progress event handling, you can work out if the refocus failed due to no data or some other reason, or if it ran OK.Code: Select all
>>> def Progress(sender, args): ... print(args.EventData) ... >>> SharpCap.Sequencer.Progress += Progress >>> SharpCap.Sequencer.RunSequence("REFOCUS") Starting : Starting : Refocus using the same settings as the most recently used autofocus run Error : 'No previous autofocus information stored, cannot refocus' while running step Refocus using the same settings as the most recently used autofocus run Info : 'No previous autofocus information stored, cannot refocus' while running step End : Sequence halted due to error. >>> SharpCap.Sequencer.Progress -= Progress Finished
cheers,
Robin
- admin
- Site Admin
- Posts: 17342
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Question about SharpCap.RunRefocus
Hi,
they are always in English - very little of the user interface is localised and even less of things like notification messages.
I will be adding a 'CanRefocus' property into SharpCap 4.2 to make this a bit easier.
cheers,
Robin
they are always in English - very little of the user interface is localised and even less of things like notification messages.
I will be adding a 'CanRefocus' property into SharpCap 4.2 to make this a bit easier.
cheers,
Robin
Re: Question about SharpCap.RunRefocus
Thank you, Robin. That would be a very welcome addition to the SharpCap scripting API. I’ll follow this topic for updates.
Regards,
Leo
Regards,
Leo