3

I am performing keystroke to a application, while performing this, application will become active. This will interrupt my current activity.

Method 1:

$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('title of the application window')
Sleep 1
$wshell.SendKeys('~')

Method 2: Importing WASP module and sending key stroke.

$window = Select-Window | Where-Object {$_.Title -like "*ApplicationName*" }
Send-Keys -Keys " " -Window $window

Both the methods will activate the application window and then send keystroke. Is there any way to send key without activating the window ?

Chand
  • 300
  • 3
  • 13
  • 2
    AFAIK keystrokes (whether invoked from any sort of Send-Keys ([SendKeys in WinAPI](https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx)) method, always go to the active window. See also [this similar question](http://stackoverflow.com/questions/1220820/how-do-i-send-key-strokes-to-a-window-without-having-to-activate-it-using-window) . – David Zemens Aug 06 '16 at 03:05

0 Answers0