1 year ago
#388085
Nero
SendKeys() in Powershell prepending and appending unwanted "=" to given string
I am attempting to use SendKeys in Windows Powershell using a ComObject:
> $wshell = New-Object -ComObject wscript.shell
> $wshell.SendKeys('Hello World')
I would expect this to 'print' "Hello World" into the input of my powershell terminal.
> Hello World
Instead, I get '=' around the string.
> =Hello World=
This behaviour is per-call of SendKeys(). Given a test script of 'Test.ps1':
#Test.ps1
$wshell = New-Object -ComObject wscript.shell
$wshell.SendKeys('a')
$wshell.SendKeys('')
$wshell.SendKeys('test')
I run it, and get:
> .\Test.ps1
> =a====test=
I am on Windows 10, version 10.0.19042. My Powershell version is as follows:
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1320
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1320
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
powershell
sendkeys
0 Answers
Your Answer