The “Hello Dolly” of piger
I created a small c++ plugin to show the basic architecture of the piger plugin.
WordPress has a very simple plugin that they called ‘Hello Dolly’, this plugin does not really do much apart from randomly displaying a lyric from “Hello Dolly”
First things first, download the latest source code of the plugin and we will talk about each files in a bit more details.
The file type:
The file is nothing more than a DLL with an ‘.amp’ extension. So when you create your plugin make sure that the output file has a ‘.amp’ extension.
The files to include:
You need to include 2 files, a header(h) file and a library(.lib) file.
1 2 3 4 5 6 7 8 9 |
// support for PluginAPI #include "../../api/amplugin/amplugin.h" // add the libs #ifdef _DEBUG #pragma comment(lib, "../../debug/amplugin.lib" ) #else #pragma comment(lib, "../../release/amplugin.lib" ) #endif |
And in the cpp file, the one and only function.
1 2 3 4 5 |
PLUGIN_API AM_RESPONSE am_Msg( AM_MSG msg, WPARAM wParam, LPARAM lParam ) { return AM_RESP_NOT_SUPPORTED; } |
Some important messages…
1 2 3 4 5 6 7 8 |
... <span style="color: #3366ff;">switch</span>( msg ) { <span style="color: #3366ff;">case </span>AM_MSG_INIT: <span style="color: #339966;">// called when the plugin is first loaded.</span> <span style="color: #3366ff;">case </span>AM_MSG_DEINIT: <span style="color: #339966;">// called when we are closing the app</span> <span style="color: #3366ff;">case </span>AM_MSG_MAIN: <span style="color: #339966;">// called when one, (or more), of the commands we </span> <span style="color: #339966;">// registered are called.</span> } |
When the message ‘AM_MSG_INIT’ is called you can add an action using the ‘addAction( … )‘ function.
AM_MSG_MAIN will be called when that action is entered.
Things to note:
- Place your plugin in the __in folder, (normally found in %appdata%\MyOddWeb\ActionMonitor_d\RootCommands\__in).
- Don’t mix debug and release builds, to debug your plugin you will need to run it again the debug version of Action monitor, (and the folder is %appdata%\MyOddWeb\ActionMonitor_d\RootCommands\__in).
- Have a look at the file “#include “am_plugins.h”“, it explains what most messages do.
- Call [Caps lock] this.reload to reload everything.
- Download the plugin code here.
Visit the forum if you have any technical questions.
Recent Comments