Andreas Hanisch
Andreas Hanisch

Reputation: 21

Send 'Enter' key to window not active via NirCmd

Dear coding enthusiasts,

In the last year I got to know the remarkable commandline tool NirCmd. With that I realized many functions on a single shortcut such as muting microphone, setting volume to predefined level, and many more. So when I need to talk via teams I can control all my sound options with any keyboard and the notebook closed. What I did not yet realize is to answer and incoming MS Teams call. NirCmd has the option to identify windows reliably.

For testing purpose I have a word file named test.docx open. When it is in the background, this NirCmd call via desktop shortcut activates it properly: nircmd.exe win activate ititle "test" So the ititle works.

No, again to test the basic principle I want to send a keystroke to the test.docx window, without activating it. It shall remain in the background.

What I have found while searching stackoverflow and other sites "[…] as Sendmsg will talk to the win api, IIRC to send keystrokes you need 0x102 and wparam the dec ascii val lower case e being 101. So try nircmd win sendmsg ititle "gamename" 0x102 101 1 – user6811411" "# send a Return to that window (0x102 is WM_CHAR and 0x0D is VK_ENTER)"

So I suspected my NirCmd call must look like this: nircmd.exe win sendmsg ititle "test" 0x102 0x0D 0

But unfortunately nothing happens. I worked on it the whole morning, searching the web endlessly, but I do not get through it. Is there anyone that can shed some light on how I can send an 'enter' keystroke to a word window in the background determined via 'ititle'?

Many thanks in advance! Best regards, Andreas

Upvotes: 1

Views: 696

Answers (0)

Related Questions