want to run two actions when pressing a hotkey I have these two actions

bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.context.tool_settings.mesh_select_mode = (True, False, False) #vertex


currently I'm running it from the text editor in blender and it works fine.

I would like to create an addon that could...
run both actions (w the vertex variation) when the Key "1" is pressed,
run both actions (w the edge variation) when the Key "2" is pressed,
run both actions (w the face variation) when the Key "3" is pressed

So far I have this script(addon) working from the text editor, n can be installed n enabled

# by EB, done with blender 2.79
bl_info = {
    "name": "EB 3Dview &gt;&gt; EditMode &gt;&gt; VertexSelect",
    "category": "3D View",
}

import bpy


class view3dEditModeVertSel(bpy.types.Operator):
#    """Edit Mode _ Vertex Select"""      # blender will use this as a tooltip for menu items and buttons.
    bl_idname = "view3d.editmode_vertsel"        # only lowercase allowed # unique identifier for buttons and menu items to reference.
    bl_label = "view3dEditModeVertSel"         # display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # enable undo for the operator.

    def execute(self, context):        # execute() is called by blender when running the operator.

        # The original script
        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
        bpy.context.tool_settings.mesh_select_mode = (True, False, False)

        return {'FINISHED'}            # this lets blender know the operator finished successfully.

def register():
    bpy.utils.register_class(view3dEditModeVertSel)
    # bpy.ops.view3d.editmode_vertsel()

def unregister():
    bpy.utils.unregister_class(view3dEditModeVertSel)

# This allows you to run the script directly from blenders text editor
# to test the add-on without having to install it.
if __name__ == "__main__":
    register()


Hi dr Sybren, ok I got the Addon working w hotkeys and all, I just was wondering, if is it possible to write the "Select Vertex", "Select Edge", n "Select Face" in a single addon, each one with its own hotkey, cuz I have seen that other blender py addons have multiple hotkeys assigned to them, please could you provide a code example for that?

btw would you know what is the difference between these two?

km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new(view3dEditModeVertSel.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)
kmi.properties.total = 4
addon_keymaps.append((km, kmi))


the former is from the Blender Addon Tut, the latter from "PieMenu Addon"

km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
kmi = km.keymap_items.new('wm.call_menu_pie', 'Z', 'PRESS')
kmi.properties.name = "pie.shade_of"
addon_keymaps.append((km, kmi))


thanks advanced.
The most future-proof way to go about this is to create your own add-on. First create an operator that performs those actions. You can then bind that operator to the keyboard, add it as a button to a panel, add it to a menu, etc.

This is all documented in Blender's documentation.