Running a script with shortkey

I wrote a script for rendering sprites for a game project. The script is very specific to my files, looking for objects with a certain name before it renders. It works great, but it’s getting tedious opening the script in Blender’s script editor to run it.

I’ve tried to figure out how to import this script to Blender in order to be able to execute it with a hotkey command, but although it appears among the add-ons, it won’t let me include it. I assume it’s because the code contains elements not allowed in the add-on system. It complains about ‘_restrictData’ object has no attribute ‘objects’.

Is it possible to get around this somehow? To somehow create a hotkey function that loads a script and runs it?

How to set up a hotkey in your addon:
http://www.blender.org/api/blender_python_api_2_73_release/info_tutorial_addon.html#keymap

Context restriction:
http://wiki.blender.org/index.php/Extensions:2.6/Py/API_Changes#Restricted_Context

Thanks for the info!