Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have 2 solutions, one that uses PowerShell, the other that uses <a href="http://www.autohotkey.com/" rel="nofollow">Autohotkey</a>.</p> <p><strong>Autohotkey version</strong> </p> <p>I would use this one ;) You define custom key and actions bound to the keys. My file contains this code:</p> <pre><code>^#n:: Run, Notepad WinWaitActive Untitled - Notepad2 Send !e Send p return </code></pre> <p>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.</p> <p><strong>PowerShell version</strong></p> <p>You need to use an editor like <a href="http://www.flos-freeware.ch/" rel="nofollow">Notepad2</a>. With switch <code>/c</code> it launches the Notepad2 and pastes the text from clipboard.</p> <p>To make it more useful I use function <code>tnp</code> defined like this: <em>(note that you need to run PowerShell with -sta parameter, otherwise they won't to work propely)</em></p> <pre><code>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() } </code></pre> <p>With these function you can run something like this:</p> <pre><code># gets list of members, opens Notepad2 and pastes the content (members list) (get-date) | gm | tnp </code></pre> <p>In other words -- if some info would be returned and formatted to screen, you can get it and paste to notepad.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload