those are technically very different questions. my Yamaha Clavinova connects to my PC via USB, but so does my external hard drive. The question "...with external USB devices" does not mean much.
As far as using AHK with MIDI devices (connection hardware does not matter), please see
Midi input library by
orbik
MIDI IN support in AutoHotkey by
hamoid
MIDI Output from AHK by
TomB (maybe could be updated per his note now that we can RegisterCallback)
Cinmidi - Console MIDI INput [CMD] by
Bobo (can be used if you want to work via CmdRet)
Midi Tools [CMD] by
Bobo (more tools)
MIDI as an input for AutoHotkey? by
daonlyfreez