Plugin Development
- Introduction
- The filename
- Plugin parameters
- Script/Function parameters
- Conventions
- Plugin Classes
- Things to Note
- Libs
- Developers Complete List
Introduction
Plugins are AutoHotkey scripts that are run by the Clipjump.exe which is nothing but AutoHotkey.exe in disguise.Some plugins are included in the program at runtime, some are not (external class). There is no limit on the number of plugins and they can be always accessed from the Plugin Manager (ActionMode = M)
The Filename
The filename of the plugin symbolizes the function it is supposed to contain.If filename is myplugin.ahk , it means the plugin file contains a
plugin_myplugin()
that is run by the Plugin Manager or API.runPlugin()
. If the filename is pformat.noformatting.ahk , the
main function the file has is plugin_pformat_noformatting()
.
Plugin Parameters
If you open any of the officially distributed plugins in Notepad, you will see lines starting with;@Plugin-
. These hold the key-value pairs that
have information about the Plugins.So
;@Plugin-Name myplugin
gives the key name for the plugin the value myplugin. As you may have guessed this is the
same thing you see when you click on Properties in the Plugin Manager.There is no limit on what can be the 'key' here. Even
;@Plugin-authorSite http://mysite.com
also works and is shown in the Properties window.
Script/Function parameters
The Plugin parameters like;@Plugin-param(N)
where N is a natural number are the Function parameters (like ;@Plugin-Param1
).
They hold information about the Nth parameter of the main function in the plugin file.
When you run a plugin with API.runPlugin( plugin_filename , param1, param2 ....)
without any 'param's , the function auto-asks you the parameters
showing these informations if they are present.
You can provide a parameter as ;@Plugin-Silent 1
to force API.runPlugin()
to not ask the user for parameters even if no parameter is passed to it.Function parameters are not Mandatory but it is recommended to provide them.
Conventions
- Variable Names in plugin files that are included (not external) should start with z. This is because Clipjump doesn't uses any variable starting with 'z' and so this is the best option to avoid variable conflicts.
- The parameter names in the function definition (
plugin_myplugin(zParam1, zParam2)
) should also start with 'z'.
STORE.myvar := "text"
and zVar := STORE.myvar
Plugin Classes
'Classes' is a way to distinguish certain plugins from normal plugins. All the plugins whose name is like a.b.ahk and not b.ahk mean they belong to a class (here a).As already said, these files have main function like
plugin_a_b()
.
Currently Clipjump has 2 defined classes. User is not allowed to create them. (i.e. create a file like xyzPlugin.coreScript.ahk)
pformat
The plugins in this class are used in the paste-format option in Paste mode (key = Z). Officially distributed plugins like pformat.sentencecase.ahk and pformat.noformatting.ahk belong to this class.- These plugins also have a custom mandatory parameter
;@Plugin-Previewable
which should hold 1 if the paste format is previewable in Paste Mode. It is 1 for SentenceCase. - These Plugins should make
STORE.ClipboardChanged
true if they have successfully changed the input variable and thus what is going to be pasted.
For exampleSTORE.ClipboardChanged := true
- It should be noted that these plugins (should) have 1 input parameter. See the file 'pformat.sentencecase.ahk' for example.
- When toggling and when pasting, Clipjump inputs the Clipboard variable and not the ClipboardAll variable as the first parameter. If the plugin needs the ClipboardAll variable, it can consult it anytime as it will be the same as what current active
external
Plugins whose name starts with external. belong to the 'external' class. They are not included in Clipjump at runtime and solely run through the AutoHotkey.exe (i.e. Clipjump.exe) when needed.The Parameters in external plugins ? Like Function parameters , the external script file can contain
-Param1
,
-Param2
and so.. for the API.runPlugin()
to take them as Script parameters and thus ask the user if they pass no paramter.For example try running the external.controller.ahk and then seeing its source code.
Things to Note
- Use
;@Plugin-Silent 1
to makeAPI.runPlugin()
not ask the user for parameters even if user doesn't enters them. - It will be a good idea to use
API.showTip()
andAPI.removeTip()
(Link) - While testing keep in mind that your plugin will be included in Clipjump.ahk and thus run from the directory of Clipjump.ahk. So be careful with the WorkingDir factor.
- There will be no auto-execution of any plugin as a non-external plugin will be included at the bottom of Clipjump.ahk
- Please reload Clipjump when you change/add a plugin file to load it into Clipjump.
- Make sure to have a look at The Complete Developer List and the public API
Libs
If your plugin file requires more files as #Includes, consider keeping them in (file_name).lib directory. So for the plugin external.controller.ahk we have external.controller.lib as the lib directory. This makes the Delete Plugin option in Plugin Manager work.Translate