Create Accelerators
Friday, November 25, 2016 3:57 AM


To explain, in detail, how to write both URL and Shell Script based Accelerators would be tiresome and confusing for the reader who has never been exposed to these concepts. Instead, this chapter focuses on getting you started with a "sneak peak" of what you can do with even basic scripting skills. By learning shell commands and URL manipulation, to make more complex "Accelerators", you will find near limitless extensions to the way you use FocalScope and automate even complex external processes.

FocalScope Accelerators use a combination of variables and scripts/URLs to combine specific data with a specific operation or tool. A variable is merely a container which is a placeholder for dynamic data. A simple variable in FocalScope is the %SELECTION% variable. Which is a "container" holding the "true data" (Any highlighted text in FocalScope).

It is much more efficient to refer to a variable than to the actual data as it makes for neater and more easily understood combinations of scripts/URLs + FocalScope data. Let's look at a very simple example for a URL Accelerator.

URL Based Accelerator


Here we can see a created Accelerator. It has aptly been named "Google Translate" and the concatenated link with the "Translator URL (Red)" + "Environment Variable" (Blue). This means the %SELECTION% variable will actually be replaced by all the text we have highlighted for translation. Since this web translator allows for text to be added to URL, which is intended for translation, we have inputted the correct sequence of URL & Data (variable) for the translator to process our request. Not all sites work this way, but with some knowledge of websites and URL's you can correctly formulate your Web Accelerator and save yourself a fair deal of repetition and time with certain tasks external to FocalScope.


Shell Script Based Accelerator


For this demonstration, A simple example script cmd /c "echo "%SELECTION%" > C:\Saved.doc && ;C:\Saved.doc && ;Exit" will be used. To properly learn how shells scripts are written, you will have to study windows shell commands and batch files, but to give you a basic idea, let's break down this script to see what it does.

cmd /c " = Opens console (Where scripts are executed)
echo = Used to write or display text
"%SELECTION%" = Our FocalScope variable holding highlighted text. Note the quotations ," ", are just to demark the exported text in the document and could have been omitted.
> = STDOUT redirector (In short: It can be used to write STREAM DATA to files or to the screen). In this case the STREAM DATA is our FocalScope %SELECTION% variable.
C:\Saved.doc = Location and name of our output document (Where the highlighted text will be written to).
&& = Run the next command once the previous one finished.
; = Delimits the next end of the previous command and start of next.
C:\Shared.doc = Opens the saved document.
Exit = Close console.




After saving the Accelerator and reloading, let's see the script in action. We highlight a line of text we wish to add to a document called "Saved.doc" which will be stored in "Drive C:\", we right click and select the Accelerator we made "Write to Document".




As soon as the accelerator runs, it copies the highlighted text, creates the file "C:\Shared.doc" and pastes the copied text into the file. We can now further edit the document and save to another name. Once we close this document, the black console that opened behind the document will close. You can write scripts that won't open a console, but doing so would obfuscate this demonstration.

Being able to get data out of FocalScope to other applications or parts of the OS and automating all the intermediary steps can be a powerful tool. With time and practice, you would be surprised what complex tasks you can do and the time and effort you'd save with Accelerators.

For more information on Shell Scripting please see this official Microsoft documentation http://technet.microsoft.com/en-us/library/cc737438%28WS.10%29.aspx.