The "Add Shortcut" button maps the keyboard key (F1 in the example above) to the command provided in the assembly.
On Microsoft's website, http://visualstudio.com, there is button labeled Free Visual Studio Trial. You can freely download and use their "Express" products to build a WriteLog Shortcut Assembly. The rest of these instructions assume you have installed Visual Studio Express Version 10 for C#. It is also possible use other .NET languages to build a WriteLog Shortcut Assembly, but only C# is described on this step-by-step page.
After installing Visual Studio Express version 10, create a new project.
Make up a name other than the name used in this example, MyWriteLogShortCuts.
The wizard generated a file named Class1.cs. In the Solution Explorer window, change the name of your Class1.cs class to something else, like ShortcutProcessor
It will ask whether to change all your references, and in this case, its useful to say Yes.
There are three assemblies (dll files) installed with WriteLog that you must add as References. All three are in WriteLog's Programs directory.
Use right mouse button and "Add Reference..."
Browse to WriteLog's Programs folder and Add Reference for WriteLogExternalShortcuts.dll and...
WriteLogExternalShortcuts.dll
WriteLogClrTypes.dll
WriteLogShortcutHelper.dll
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
MyWritelogShortcuts
{
public class ShortcutProcessor
: WriteLogShortcutHelper.ShortcutHelper
{
/* These are
the names of the commands as they will appear
in WriteLog's Keyboard Shortcuts
"Command to run" list: */
string[]
CommandNames = new string[]
{
"My
command 1", // this is which == 0
"My
command 2" // this is which == 1
//
... and you can add as many as you like.
//
They will appear in WriteLog with "External:" prepended.
//
Look in the E's in that menu.
};
// you must
have this property
public override int
ShortcutCount
{ get { return CommandNames.Length; } }
// and you
must have this one
public override string this[int which]
{
get
{
if
((which < 0) || (which >= CommandNames.Length))
throw
new IndexOutOfRangeException();
return
CommandNames[which];
}
}
// and you
must have this method
public override void
InvokeShortcut(int which, WriteLogClrTypes.IWriteL wl)
{
if
((which < 0) || (which >= CommandNames.Length))
throw
new IndexOutOfRangeException();
// you
can call methods on the wl object here. You are not limited
// to the
InvokeKeyboardCommand, but it makes a simple demonstration
//
because the result is to simply do exactly what WriteLog would
// do if
you set the CommandToRun to ToolsGraphs or ViewOnlyTheLog.
switch
(which)
{
case 0: // "My command 1" does two existing keyboard commands in sequence
wl.InvokeKeyboardCommand("RadioHeadphonesSplit");
wl.InvokeKeyboardCommand("MessageShift09");
break;
case 1: // My command 2"
wl.InvokeKeyboardCommand("ViewOnlyTheLog");
break;
}
}
}
}
The sample above simply uses the InvokeKeyboardCommand method to invoke one (or two) of the commands that WriteLog's own Keyboard shortcut editor can also invoke. If you learn C# programming, you can figure out how to make the your shortcut do much more. It can, for example, query the frequency and mode the radio is tuned to, it can read and write the fields in the Entry Windows, and it can command the radios to change frequency or modes and more.
Here you can download a sample that was created using the above instructions. Download sample
The sample also includes the project KeyboardShortcutTester.sln. Open it first and Visual Studio will open not only the sample, but also a project with a debugging tool that works with Visual Studio Express.To make WriteLog see your shortcuts, you must do three things:
[Configuration]
ExtShortcutAssembly=MyWritelogShortcuts
Use the name of your DLL, but without the .dllExtShortcutClass=MyWritelogShortcuts.ShortcutProcessor