Thank you for explaining. I understand what you wrote, but I do not follow your script so well, so I cannot adjust it. Sorry about that. I was providing a script as a way to demonstrate how you can use hotkeys to change the suspension state, in a way that might be more reliable than your script. The adjustment seems easy because you have control over every suspension event and hotkey. If it does not work for you, then OK, I will be quiet so that others can respond.
One additional suggestion that I have for you is that if you want to wait for a certain key, you can use
Input instead of running an infinite loop.
You have written the following:
1. F6 is a toggle which suspend script and unsuspend it.
2. I want that F6 is turned off (If I click F6 it can't unsuspend script) until I click enter/esc key.
This looks like a contradiction to me-- and perhaps is why we have not solved the issue for you. If you can explain this apparent contradiction, it might help others as they look to find solutions for you. Best wishes.