I have 2 solutions, one that uses PowerShell, the other that uses Autohotkey.
Autohotkey version
I would use this one ;) You define custom key and actions bound to the keys. My file contains this code:
^#n::
Run, Notepad
WinWaitActive Untitled - Notepad2
Send !e
Send p
return
It runs notepad2 and then simulates pressing Alt+E and P. That pastes the string the same way as you would press it by yourself. From some reason I had some problems with 'pressing' Ctrl+V (I don't remember that any more). For more info have a look at Autohotkey's website.
PowerShell version
You need to use an editor like Notepad2. With switch /c
it launches the Notepad2 and pastes the text from clipboard.
To make it more useful I use function tnp
defined like this:
(note that you need to run PowerShell with -sta parameter, otherwise they won't to work propely)
function tnp {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[object]
$InputObject
)
begin { $objs = @() }
process { $objs += $InputObject }
end {
$old = Get-clipboard # store current value
$objs | out-string -width 1000 | Set-Clipboard
notepad /c
sleep -mil 500
$old | Set-Clipboard # restore the original value
}
}
function Set-Clipboard {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)][object]$s
)
begin { $sb = new-object Text.StringBuilder }
process {
$s | % {
if ($sb.Length -gt 0) { $null = $sb.AppendLine(); }
$null = $sb.Append($_)
}
}
end { Add-Type –a system.windows.forms; [windows.forms.clipboard]::SetText($sb.Tostring()) }
}
function Get-Clipboard {
Add-Type –a system.windows.forms
[windows.forms.clipboard]::GetText()
}
With these function you can run something like this:
# gets list of members, opens Notepad2 and pastes the content (members list)
(get-date) | gm | tnp
In other words -- if some info would be returned and formatted to screen, you can get it and paste to notepad.