Generalkidd
Generalkidd

Reputation: 579

Send keystrokes to other applications

I'm trying to write a program in C# that lets me send a keystroke to another program that's open but is not in the foreground. The purpose of the program is to let me start recording gameplay footage from my Xbox 360 using TotalMedia Extreme while also starting recording in audacity to record from the PC mic. That way I can get both tracks to be synced instead of starting gameplay recording and quickly switching to audacity and clicking record.

Basically all I need this program to do is detect a mouse click while TotalMedia Extreme is in the foreground and when the mouse is clicked, send the hotkey command to Audacity to start recording. Does anyone have an idea for how I could get started with this?

This seems like it might be a good place to start, but I don't think it will do the same thing I need to do:

Send fast textinput to another process (Window)

Upvotes: 0

Views: 170

Answers (3)

Paul Leavitt
Paul Leavitt

Reputation: 55

AutoHotKey is definitely the rout I'd go. You can use a function called ControlSend to send keystrokes to specific controls of specific applications, even if they're in the background. Sounds like it would work perfectly for what you're needing. The forums over at AHKScript.org are really helpful too, so you might check them out as well!

Upvotes: 0

Nate Zaugg
Nate Zaugg

Reputation: 4218

Just use AutoHotKey. The command SendMessage will send keystrokes to a non-active window, but you could also just have AHK activate the right window before sending keystrokes. Once you are done you can wrap it into a handy little hotkey or even compile it into an exe file.

Upvotes: 0

Saverio Terracciano
Saverio Terracciano

Reputation: 3915

Check this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589(v=vs.85).aspx I suppose you could do it through Windows Hooks, in particular WH_KEYBOARD_LL

Upvotes: 1

Related Questions