Plugins

From Synergy Wiki
Jump to: navigation, search

As of 1.4.9, Synergy offers support for 3rd party plugins on Windows (other OSs may be supported in future).

Contents

Usage

To use a plugin, simply create a folder named "plugins" in the same directory as your synergyc/synergys binaries. Then drop the plugin (it should be a DLL) into the plugins folder.

Writing plugins

Writing plugins for Synergy is easy. All you need is some existing knowledge about C++ and writing simple DLLs.

Hello world

Here's an example:

// demoplugin.h

#pragma once

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#if defined(DEMOPLUGIN_EXPORTS)
#define DEMOPLUGIN_API __declspec(dllexport)
#else
#define DEMOPLUGIN_API __declspec(dllimport)
#endif

extern "C" {
DEMOPLUGIN_API int init(void (*sendEvent)(const char*, void*), void (*log)(const char*));
DEMOPLUGIN_API int cleanup();
}
// demoplugin.c

extern "C" {

int
init(void (*sendEvent)(const char*, void*), void (*log)(const char*))
{
	log("hello world!");
	return 0;
}

int
cleanup()
{
	log("goodbye world!");
	return 0;
}

}

Raising events

It is possible to talk to Synergy by raising events. The first parameter of the init function, sendEvent is a function pointer, which you can call like this:

sendEvent("IPrimaryScreen::screensaverActivated");

There is a limitation currently that only primary screen events can be raised, and the event target is also ignored. For a full list of events which can be raised on the primary screen, please see the \src\lib\synergy\IPrimaryScreen.cpp file.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox