Enable / Disable transform modal shortcut in script


Is it possible to enable and disable a transform modal hotkey with a script? I’m trying to have get some keys to only be active if a condition was met before.

I am talking about modals that already exist in the Transform modals, I am not trying to add new modals (which seems impossible, from what I read).