tags:

views:

53

answers:

1

Is it possible to send text to the current prompt line? Something like the following:

PS[10]> Get-Location
c:/
PS[11]> Write-PromptLine "This text has been written by Powershell"
PS[12]> This text has been written by Powershell|
# | denotes the caret
+2  A: 

You could use the SendKeys.SendWait method:

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("This text has been written by Powershell")
Paolo Tedesco
I was hoping the `$host` object would provide that functionality, but I'll try later whether your approach would work for me. Thanks.
guillermooo
I couldn't find anything in $host (that's the first thing I tried), but SendKeys does what you asked for. What are you trying to accomplish, exactly?
Paolo Tedesco
Send last cmd line to editor, block execution of shell, edit cmd in editor, save to temp file, close editor and send result to PS prompt line without executing straight away. Can't test right now, though. Your solution should work.
guillermooo