Messages - PaulM [ switch to compact view ]

Pages: [1] 2next
1
Clipboard Help+Spell / Re: Writing custom script...?
« on: June 09, 2015, 01:02 AM »
Hi:

Perhaps there's one thing that someone here can help me understand better...  When something gets copied to the clipboard what are the conditions that determine whether or not Clipboard Help+Spell will save the current entry,... that is, push the current clipboard entry onto it's stack or queue?  As opposed, perhaps, to the current entry just being overwritten, and not being pushed onto Clipboard Help+Spell stack or queue?

Is this determined entirely by Clipboard Help+Spell, or does it depend entirely on the particular method used to place contents on the clipboard, or is it some combination of the two?

Thanks

2
Clipboard Help+Spell / Re: Writing custom script...?
« on: June 01, 2015, 12:25 PM »
For what it's worth, this is the basic Powershell script I was messing with... this works on on one computer with Powershell 5.0.  I have another computer with Powershell 5.0 and it doesn't work... so, I've given up figuring out what's going on!  I did try the iterative Foreach, as well... seems to have the same behavior, so... I don't know.  But, anyway, when I try to run it from Clipboard Help+Spell, it just brings up a Windows Explorer window of the Clipboard Help+Spell directory...?!?  You don't what to see the copy with all the comments indicating all the changes... it's a total mess!

# powershell -ExecutionPolicy Bypass -File Drive:\Path\to\file\ClipboardEntryParse.ps1

function Get-Clipboard([switch] $Lines) {
   if($Lines) {
      $cmd = {
         Add-Type -Assembly PresentationCore
         [Windows.Clipboard]::GetText() -replace "`r", '' -split "`n"
      }
   } else {
      $cmd = {
         Add-Type -Assembly PresentationCore
         [Windows.Clipboard]::GetText()
      }
   }
   if([threading.thread]::CurrentThread.GetApartmentState() -eq 'MTA') {
      & powershell -Sta -Command $cmd
   } else {
      & $cmd
   }
}

function Out-Clipboard {
    [cmdletbinding()]
    param (
        [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)]$InputObject,
        [switch] $File
    )
    begin {
        $ps = [PowerShell]::Create()
        $rs = [RunSpaceFactory]::CreateRunspace()
        $rs.ApartmentState = "STA"
        $rs.ThreadOptions = "ReuseThread"
        $rs.Open()
        $data = @()
    }
    process {$data += $InputObject}
    end {
        $rs.SessionStateProxy.SetVariable("do_file_copy", $File)
        $rs.SessionStateProxy.SetVariable("data", $data)
        $ps.Runspace = $rs
        $ps.AddScript({
            Add-Type -AssemblyName 'System.Windows.Forms'
            if ($do_file_copy) {
                $file_list = New-Object -TypeName System.Collections.Specialized.StringCollection
                $data | % {
                    if ($_ -is [System.IO.FileInfo]) {[void]$file_list.Add($_.FullName)}
                    elseif ([IO.File]::Exists($_))    {[void]$file_list.Add($_)}
                }
                [System.Windows.Forms.Clipboard]::SetFileDropList($file_list)
            } else {
                $host_out = (($data | Out-String -Width 1000) -split "`n" | % {$_.TrimEnd()}) -join "`n"
                [System.Windows.Forms.Clipboard]::SetText($host_out)
            }
        }).Invoke()
    }
}



$text = [String]::Join(' ', (Get-Clipboard))
  [regex]::Matches($text, '(\w+(?:[-'']\w+)*)') |
  ForEach-Object { Out-Clipboard $_.Value  }

3
Clipboard Help+Spell / Re: Writing custom script...?
« on: June 01, 2015, 12:14 PM »
That'd be great!  I'll post my solution if I actually get something to work halfway reliably...!

4
Clipboard Help+Spell / Re: Writing custom script...?
« on: June 01, 2015, 02:21 AM »
I don't know why this didn't occur to me before... AutoHotkey!  And there is a .ahk to .exe converter!  That's got to be easier than trying to do it with VB...

5
Clipboard Help+Spell / Re: Writing custom script...?
« on: May 31, 2015, 08:59 PM »
Last line should read:

I'm hoping that someone here might be able to show me some code that allows a VB.net CONSOLE program to access the System.Windows.Forms clipboard functions without generating a compile error...?

Pages: [1] 2next
Go to full version