Simulate a keystroke from a button

From 13 years ago:

How do I run AutoHotkey via the command-line from the button? I want my button to send #F11.

Do you mean to run an AHK file? That I know how to do, but I'd rather not have a specific AHK file for every hot string use. AHK is running in the background and listening for my hot strings. I just want an OPUS button to simulate a keystroke combo.

Why not run the thing that F11 triggers directly?

But if you really want to generate keyboard input, search the forum for “SendKeys” which finds a bunch of threads about how to do it.

True, I didn't think of that! The AHK just changes my sound device between speakers and headphones, using nircmd.

  #F11::RUN "[PATH-TO-NIRCMD]\nircmd.exe" setdefaultsounddevice Speakers
  #F12::RUN "[PATH-TO-NIRCMD]\nircmd.exe" setdefaultsounddevice LGULTRAWIDE

I added these two buttons, and they work!

@filesonly
@async: [PATH-TO-NIRCMD]\nircmd-x64\nircmd.exe" setdefaultsounddevice Speakers

@filesonly
@async: "[PATH-TO-NIRCMD]\nircmd-x64\nircmd.exe" setdefaultsounddevice LGULTRAWIDE

Thanks!