Hey Yevgeny,
Good job on figuring out the AppleScript!
In future please use proper code-blocks for AppleScript and any other code.
See this thread for the basics:
Code Block Fencing on the Keyboard Maestro Forum and Paste AppleScript as Markdown Macro
I've adjusted the post above for you already.
--
Best Regards,
Christopher Stone (Keyboard Maestro Moderator)