« on: May 31, 2015, 08:53 PM »
I've been attempting to write a custom script to complement Clipboard Help+Spell, but I've been having so much difficulty I thought it might be time to ask for some help...
I use Clipboard Help+Spell on my computers at home and also at work. It's a nice program,... I appreciate the effort that's gone into creating it. I do have some experience with scripting and even some experience with complied coding, but largely that's when I was getting my computer science degree, which was in 2002. So, I haven't done much complied coding in a long time.
Mostly I'm trying to find a way to parse the current clipboard entry into words. This would mostly be helpful at work. However, installing Clipboard Help+Spell is probably about they'll let me install on my computer at work. Consequently, I'm limited in the tools I can use to solve this problem.
At first I thought maybe I could just do it in Batch, but I don't think there's any native way to get the clipboard's contents from Batch. Clip will copy to the clipboard, but it gives you a newline character, which I don't want. Further, once I decided that I really needed a regex to do any decent job of parsing the words out of the current clipboard entry and all that's naively available in Batch for regexes is Findstr... although perhaps I could do the job with Findstr, it's not a good regex processor... and I still can't get the clipboard's contents. There are Batch add-ons which perhaps I could get away with putting on the computer at work, but the computer at work does have Powershell 3.0 and there are ways to get around having to change the execution policy... and, doing all these things in Powershell should be easier.
Perhaps someone else has an idea I haven't thought of, but I haven't thought of any way of doing what I want just within Clipboard Help+Spell. The major obstacle here from what I know is taking one clipboard entry and making multiple entries from that. So, one way or another, unless I'm missing something, I need some sort of custom script, although perhaps it could be a Quick Action? What's more, I don't believe Clipboard Help+Spell's default mechanism of exchanging information with a custom script by passing the custom script an input and output file is going to work here... unless perhaps the script is called multiple times for each word parsed from the current clipboard entry. Because... I don't believe there's any way to tell Clipboard Help+Spell that the output file contents aren't supposed to all be all one clipboard entry? So, I decided it'd probably be best to have the script itself read the current clipboard entry and, of course, paste back separate clipboard entries for each word parsed from the current clipboard entry.
So, I devised a script that works with Powershell 5.0,... well, at least on one of my computer's at home which has Powershell 5.0. Powershell 5.0 does now have native ability to copy and paste to the clipboard with a couple new utility cmdlets. However, the scripts I'm using to copy and paste to the clipboard were targeted at earlier versions of Powershell... I'm not really certain why I can't find a Powershell script that appears to work as I wish in an earlier version of Powershell, particularly Powershell 3.0. What's more, when I try to run it as a custom script from Clipboard Help+Spell, all that happens is an Windows Explorer window opens to the Clipboard Help+Spell directory. However, even if I could get one of these Powershell scripts to run correctly from Powershell, none of them I've tested give all the words in the current entry... at least not in Powershell 3.0. It doesn't seem to matter if I do it through the pipeline or iteratively, it won't do it correctly in Powershell 3.0.
So, I decided to try another scripting language and see if I can make it an exe... then, perhaps I can use that on the computer at work. Perl was my first choice because there are so many libraries for Perl, so just everything you might want to do has already been done,... better than I could ever do anyway. However, the problem with this approach is trying to find a way to make a Perl file into an exe... It appears that's probably not viable, at least on 64-bit machine unless you have hundreds of dollars, at least at this time. My impression is that the situation isn't much better with Ruby or Python. Yes, I did think of a standalone VBScript, but the limitation here appears to be that Wscript and Cscript can only access the clipboard through Internet Explorer, and that always pops up a security warning...
So, then I said let's download Visual Studio 2015 and try a VB.net script... The problem here is that these IDE's are really complicated nowadays and I'm stumped on numerous fronts here... The most immediate problem is that I want a VB.net console application that accesses the clipboard, preferably through System.Windows.Forms, but no matter how many times I find another message board topic that says this should be no problem, I try to do as they instruct and I still always get a compile error. The regex I have for Powershell works fine as it's a .NET regex, as is the regex for VB.net. I'm hoping that someone here might be able to show me some code that allows a VB.net program to access the System.Windows.Forms clipboard functions without generating a compile error...?