ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > FARR Plugins and Aliases

FARR plugin: Akete

(1/14) > >>

ewemoa:
Akete - FARR-specific file associations

Purpose

  FARR enables customization of the browser and/or file explorer used to "launch" URLs and files/folders respectively.  This plugin generalizes this idea for files based on filename extensions.  

  The original motivation for this plugin was to enable one to make use of and transport file associations without getting involved with the registry -- e.g. for portable application types of settings -- well, at least for files launched via FARR :)

Usage

  To customize the handling for a specific file extension, first ensure that FARR's "Program Options -> Lists -> User Variables" setting has an [Akete] section.  

  Then create a line in that section of the form:

    <extension>=<executable-path>

where <extension> stands for the (typically 3-letter) file extension in question and <executable-path> is an appropriate path to an appropriate executable.

  For example, to handle PDF files using SumatraPDF, one might use the following sort of text (assuming here that SumatraPDF.exe is the name of the executable and that it lives in D:\Apps\):

    [Akete]
    pdf=D:\Apps\SumatraPDF.exe

  If all goes well, FARR should now launch all files that end in '.pdf' using SumatraPDF.

Credits

  Thanks go out to:

    mouser
    ecaradec
    phitsc
    Plugin authors that provided source and/or comments on the forums
    DC Forums participants
    DC Supporters

Download

  Stable MD5: 1c2fb4e40841437c48cf3f5070d9fa66
  Experimenting MD5: 58ebf5cc5a6b2ffa1a3c76a3348fccc1

If trying the Experimental version, please make sure to install the plugin in FARR's Plugins folder and name the folder for the plugin "Akete".

  README for Experimental VersionAkete - FARR-specific file associations

Introduction
------------

The main point of this plugin is to be able to customize how files
with particular file extensions are opened.  To achieve this end,
the user is expected to provide a configuration which specifies
associations between file extensions and corresponding methods of
opening files with those extensions.

The plugin provides additional functionality including support for:

  * multiple possible methods of opening files via context menu items

  * default context menu items (i.e. always appear in context menu)

  * overriding of method to open files via an appropriate keyword

Configuration
-------------

The Akete plugin may be configured by using FARR User Variables.

FARR User Variables are accessible via "Program Options" ->
"Lists" -> "User Variables" in FARR's Options dialog box.  The section
for Akete (may not exist unless manually created) begins with the
string [Akete].  (For more information regarding FARR User Variables,
in FARR's .chm Help File, see the section titled "User Variables -
Advanced Use" under "Advanced Use".  The rest of the text assumes
familiarity with the FARR documentation content.)

Configuration details will be demonstrated through a series of examples.
After each example a general rule will be stated possibly followed by
some related notes.

Example 1

A configuration to get files with the extension 'txt' to be opened using
Wordpad might be:

  [Akete]
  txt=%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe

Rule 1: <file-extension>=<path-to-executable>

Notes: The path to the executable may contain FARR Virtual Folder
names (see the FARR help file).  Also, file extensions do NOT contain
the period character.

Example 2

A configuration to get files with the extension 'txt' to be opened by
(possibly additional instances of) Notepad++ might be:

  [Akete]
  txt=%PROGRAMFILES%\Notepad++\Notepad++ -multiInst "$$1"

Rule 2: <file-extension>=<launch-template-string>

Notes: The launch template string allows specification of command line
arguments.  The plugin replaces the string $$1 by the path to the file to
be opened.  Do NOT use the vertical bar character in a launch template
string -- the reason for this should become clear below.

Once a file extension has been associated with a path or launch template
string, it is possible to leverage this association so that any file
specified via FARR's text edit field is opened using the associated
path or launch template string.

For the examples above, if the text in FARR's text edit field looks like:

  C:\boot.ini +withtxt

"launching" via FARR will open the file with path C:\boot.ini using
Wordpad in the case of the first example, and Notepad++ in the case of
the second example.

Notes: The keyword is assembled by prepending the file extension with the
string "with" (the default keyword prefix string).

Example 3

A configuration to override the default keyword prefix string with the
string "open" instead of "with", might be:

  [Akete]
  Options.KeywordPrefix=open

Rule 3: Options.KeywordPrefix=<keyword-prefix-string>

Notes: The user variable name is the fixed string "Options.KeywordPrefix".  
The user variable value should probably be kept to a string composed of
numbers and letters -- other values such as spaces, pluses, and the like
are not likely to work.  It may also be safer to not use uppercase letters
in the user variable value.

Example 4

A configuration to get files with the extension 'doc' to be opened using
whatever is configured for 'txt' might be:

  [Akete]
  txt=%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe
  doc=txt

Rule 4: <file-extension>=<file-extension>

Notes: For simplicity of configuration and implementation, if a file
extension appears on the right hand side of an equals sign, it may not
appear on the left hand side of the equals sign.  Another way to phrase
this is that only one level of indirection is supported.

Example 5

A configuration to get the context menu of a file with extension 'txt'
to show context menu items for opening via Wordpad and Notepad++ might be:

  [Akete]
  txt=%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe|%PROGRAMFILES%\Notepad++\Notepad++ -multiInst "$$1"

Rule 5: <file-extension>=<list-of-paths-or-templates>

Notes: The items in the list may be paths or launch string templates.  
The vertical bar character is reserved for separating the items so it may
not be used in a path (doesn't tend to work in Windows anyway?) or a
launch template string.  Opening of files via FARR's text edit field will
be handled using the first item in the list.  It may be worth noticing
that a single path or launch template string might be viewed as a list of
one item.

A configuration to get the context menu of a file with extension 'txt'
to show context menu items for opening via Wordpad and Notepad, but leaves
handling of opening of such files untouched if done via FARR's text edit
field might be:

  [Akete]
  txt=|%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe|C:\Windows\System32\notepad.exe

Notes: One can think of the list as having an empty first item.

Example 6

A configuration to get a file without a file extension to be opened by
Emacs might be:

  [Akete]
  Options.NoExtension=%PROGRAMFILES%\Emacs\bin\runemacs.exe

Rule 6: Options.NoExtension=<file-extension-or-list-of-paths-or-templates>

Example 7

A configuration to get the context menu of any file to show context menu
items for opening via Wordpad, Notepad, and Emacs might be:

  [Akete]
  *=%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe|C:\Windows\System32\notepad.exe|%PROGRAMFILES%\Emacs\bin\runemacs.exe

Rule 7: *=<list-of-paths-or-templates>

Notes: One can think of the asterisk character as similar to a wildcard
pattern character.

In summary, the types of user variable names (strings to the left of the
equals sign) that may be specified include:

  1) file extension
  2) Options.NoExtension
  3) *
  4) Options.KeywordPrefix

and the types of user variable values (strings to the right of the equals
sign) that may be specified include:

  1) list of paths and/or launch templates
  2) file extension

Bugs
----

Probably ;)

Credits
-------

Thanks go out to:

  mouser
  ecaradec
  phitsc
  raybeere
  Plugin authors that provided source and/or comments on the forums
  DC Forums participants
  DC Supporters



git repository containing code with various changes and restructuring

README.txtAkete

Purpose:

  To enable one to create, edit, make use of, and transport
  FARR-specific file associations.

Requirements:

  Tested with:

    - Windows 7 - may work for other versions of Windows

    - FindAndRunRobot 2.203.01 - may work for other versions

Example Usage:

  To get FARR to handle PDF files using SumatraPDF:

    Method 1:

    1. Bring up FARR's main window.

    2. Type the following in to the text field: .pdf

    Assuming FARR can find some PDF files, this should result in
    a number of FARR results representing PDF files.

    3. Bring up the context menu for one of the PDF file results.

    4. Choose the "Edit file assocation: pdf" menu item.

    FARR should switch to a view with a form requesting a path.

    5. Enter the full path to SumatraPDF.exe in the text field
       and click the button labeled "update".

    Method 2:

    1. Bring up FARR's Options dialog box.

    2. Select the Program Options -> Lists -> User Variables section.

    3. If there is no [Akete] section, add one.

    4. Under the [Akete] section, add text similar to:

         pdf = c:\apps\SumatraPDF\SumatraPDF.exe

       where the portion to the right of the equals sign is an
       appropriate path to the SumatraPDF.exe file.

  Subsequent to such configuration, in FARR, launching a file whose
  name ends in .pdf should use the SumatraPDF application do open the
  file.

Notes:

  There are other under-documented features including:

    1. Specifying more than one executable for a particular file
       association.

       Multiple paths are separated by the | character.

       For example:

         txt = c:\windows\system32\notepad.exe|c:\apps\Notepad++\notepad++.exe

       The first one mentioned is what FARR will use when launching
       normally.

       If a context menu for a result is displayed, each of the listed
       paths should appear as options for opening the file with.

    2. Specifying a "template" instead of an executable file path.

       A "template" to be filled in with the path of a FARR result
       may be specified -- the "slot" is represented by $$1

       For example:

         zip = c:\apps\NirLauncher\NirSoft\HashMyFiles.exe /file "$$1"

    3. A wildcard may be specified as a file extension so particular
       executable paths or templates will always show up on a FARR file
       result's context menu.

       The * character is used to represent the wildcard file extension.

       For example:

         * = c:\apps\Notepad++\notepad++.exe

    4. Specifying executable paths or templates for operating on FARR
       folder (not file) results.

       For example:

         Folder.* = c:\NirLauncher\NirSoft\HashMyFiles.exe /folder "$$1"
   
    5. Specifying the path to certain applications' ini files to utilize
       file association information configured for those applications.

       For example:

         IniPath.QDir = c:\apps\Q-Dir\Q-Dir.ini
         IniPath.Xenon = c:\apps\XenonPortable\Data\settings\assoc.ini

Credits:

  Find And Run Robot

    mouser

  FScript

    ecaradec

  Discussion and Testing

    JaneDC
    komtak
    mouser
    nitrix-ud
    phitsc

  Icons

    https://www.fatcow.com/free-icons

  General Thanks

    Plugin authors that provided source and/or comments on the forums
    DC Forums participants
    DC Supporters

phitsc:
Hi ewemoa. Good start :Thmbsup:. The plugin doesn't work as expected on my system though unless I assign something (anything, that is) to aliasstr. This reminded my of the problem I had when I was working on my (never released) OpenWith plugin. The onSearchBegins function was never called because I had left the default alias empty (because the plugin didn't need an alias). Maybe it's the same with onProcessTrigger?

Anyway, speaking of my never released OpenWith plugin. I think we've already concluded that the OpenWith plugin and your Akete plugin are similar. Maybe it would be a good idea to extend your Akete plugin to allow definition of "open with" keywords (using FARR's +keyword syntax) to launch files having the same file extension with different applications (what the OpenWith plugin does). I imagine something like this:

  [Akete]
    pdf=D:\Apps\SumatraPDF.exe
    OpenWithNpp=C:\Program Files\Notepad++\Notepad++.exe

and Akete not only launching .pdf files but also something like this: c:\My cool project\Config.xml +OpenWithNpp

I explained why I would like to have this functionality here by the way. The reason I never released the OpenWith plugin is that FARR keyword modifiers can't have spaces, i.e. something like +openwith=c:\program files\blah\blah.exe doesn't work. But by using defined keywords this would obviously not be a problem. With Akete doing this I could ditch the OpenWith plugin and would have something less to take care of ;)

Philipp

ewemoa:
Thanks for the feedback and sharing of ideas :)

The plugin doesn't work as expected on my system though unless I assign something (anything, that is) to aliasstr.
-phitsc (December 15, 2008, 04:42 PM)
--- End quote ---

Strange.  What version of FARR are you using?  I just tested it locally with 2.34.01 and it looks like it works for me without modification.  Hmmm...

This reminded my of the problem I had when I was working on my (never released) OpenWith plugin. The onSearchBegins function was never called because I had left the default alias empty (because the plugin didn't need an alias). Maybe it's the same with onProcessTrigger?

--- End quote ---

Good question.

Anyway, speaking of my never released OpenWith plugin. I think we've already concluded that the OpenWith plugin and your Akete plugin are similar.

--- End quote ---

It is thanks to your generous sharing earlier that contributed to the birth of Akete ;)

Maybe it would be a good idea to extend your Akete plugin to allow definition of "open with" keywords (using FARR's +keyword syntax) to launch files having the same file extension with different applications (what the OpenWith plugin does). I imagine something like this:

  [Akete]
    pdf=D:\Apps\SumatraPDF.exe
    OpenWithNpp=C:\Program Files\Notepad++\Notepad++.exe

and Akete not only launching .pdf files but also something like this: c:\My cool project\Config.xml +OpenWithNpp

--- End quote ---

I think I follow this suggestion.  I intend to consider and experiment with trying to implement this.  I have been wary of using keywords in FARR because I have experienced difficulties working with them.  May be I can use this as an opportunity to improve my understanding.

Thanks for posting!

ewemoa:
I've thought about this a bit more and I think there may be at least one difficulty w.r.t. implementing the proposal.  IIUC there isn't an easy way to programmatically enumerate the names of variables in User Variables (yet). 

I suppose I could try to parse FARR's ini file, but I don't think I want to go that route.

Another possibility is to use a different form of configuration in User Variables.  If all of the pairings of "OpenWith<X>", "<Path>" were stored in a different format -- e.g. as a kind of associative array under a single name -- then there would be no necessity of determining variable names because there would only be one hard-wired one.  I believe czb has applied this method in at least one (may be two or more) of his plugins -- through the use of JSON.  One potential drawback to this approach is that editing of User Variables becomes much more complex.

mouser:
IIUC there isn't an easy way to programmatically enumerate the names of variables in User Variables (yet).
--- End quote ---

i can add this easily in the new version to be released this week.

Navigation

[0] Message Index

[#] Next page

Go to full version