Skip to Content

Tag: Autohotkey

    A Modular Hotkey System (AutoHotKey)

    For my StrangeLoop workshop I had to do a lot of powerpoint work. To streamline this, I made over 20 AutoHotKey shortcuts to run various ribbon commands. To avoid polluting my keyboard I built them all into a general-purpose system. All shortcuts started by clicking the thumb mouse button and then quickly pressing 1-2 keys in sequence.

    #IfWinActive ahk_exe POWERPNT.EXE
    
    pp_func() ; making this a function allows for local variable scopes
    {
        pp_cmd := {a2: {cmd: "{alt}adu.2", info: "Set animation time to .2 seconds"}
        , af: {cmd: "{alt}as{home}{down}{right}{enter}", info: "Insert fadein animation"} ; etc etc etc
        , gc: {cmd: "^g{alt}hgac{alt}hgam^+g", info: "center as a group"}} ;closer can't be on newline
    
    pp_input := "?"
    pp_info := ""
    for pkey, pval in pp_cmd {
        pp_input .=  "," . pkey
        pp_info .= pkey . "       " . pval["info"] . "`n"
    }
    
    Input, PowerPointCommand, L2 T1,, %pp_input%
        if (ErrorLevel == "Match") {
            if (PowerPointCommand == "?") {
                MsgBox,,, %pp_info%
            }
            else {
                p_cmd := pp_cmd[PowerPointCommand]["cmd"]
                Send, %p_cmd%
            }
        }
    return
    }
    
    ; Mouse thumb button, you can change this to something else
    XButton1::pp_func()
    #IfWinActive
    

    Pressing ? will show all of the commands along with descriptions.

    How it Works