How to fetch current mails in a folder, without moved ones

I process emails from Mail’s Inbox.

However, if I then move mails out of the inbox to another box, even by hand, and re-run my script, the script is still getting the same mails even though they’re not any more in the targeted inbox.

The only remedy I found so far is to restart Mail.

This appears to be a long-standing bug, as documented in this old post on this forum:

Have any other solutions been found in the mean time to have Mail get us the actual mails from the targeted mailbox, without restarting it?

My currently work-around is to remember the processed messages in a property of the script, and check for those when I re-run the script, but that’s not a good solution, either (e.g. when I edit the script, the props are cleared and then I run into this problem again unless I also remember to restart Mail).