Step 1: Create a new macro.

Step 2: Enter the macro script below.
if (komodo.view) { komodo.view.setFocus() };
komodo.doCommand('cmd_save')
ko.run.runEncodedCommand(window, '%(python) -O \"%F\" {\"cwd\": u\"%D\"}');
You are free to change %(python) to %(perl), provided that perl is installed, and the environment path is set.komodo.doCommand('cmd_save')
ko.run.runEncodedCommand(window, '%(python) -O \"%F\" {\"cwd\": u\"%D\"}');

Step 3: Set a key binding to the new created macro.

Now you just need to press the 'F5' key inorder to save and run a python script.