Just a quick update that I think this idea may be a dead end, sadly.
First, You need to manually ensure the Canon menu is on the auto clean setting, before running the script. It is no good being on the clean now setting, as after cleaning the sub menu always opens on the auto setting, ie you need to click move to clean now. This is not a killer issue for me.
Second, repeatedly clicking clean now, not only results in the sensor clean sub menu item defaulting to auto each time, requiring a click move to get to the do now state, it also takes a long time for the Canon side to re-enable the clean now setting, some 12-15 seconds, which could be the main killer of the idea, ie 16 images, say, taking an extra 3-4 minutes to capture
Nevertheless, I’ll likely still code it up and test it for fun, and reserve judgement as to whether I include it in my published M3 landscape bracketing script. It may have a niche use.