Project 1: TrackPie! Spawning PieMenus from TrackPoints

Aim: when the TrackPoint is pressed, a pie Menu appears around the mouse cursor. The TrackPoint can then be used to select the desired item by moving it in the appropriate direction and releasing.

this is a very old page. practically everything here is redundant now. I have coded this using C#. however I leave it because the old links may be interesting to some...

here are some good examples of pie menus:

and here is the ActiveX pie Menu object piemenu.ocx which created them:

I want to use this object.

AutoHotKey (AHK) is a scripting language optimised for remapping of mouse and keyboard
This should give some idea:
Also have a look at this link:
As you can see this is a very functional scripting language

I want to use AutoHotKey

The first task is to make piemenu.ocx accessible for use in an .AHK script. An .AHK script cannot comprehend an ActiveX object. But it can handle a DLL.
also it can listen for messages

TASK 1: Write wrapper.dll; a DLL wrapper for piemenu.ocx

the Properties Events and Methods of piemenu.ocx are listed here:

this is what wrapper.dll needs to do:

int wrapper::Getproperty ("ItemCount");
wrapper::SetProperty ("ShapeWindow", 5); 5 is spokes

events are passed back to the .AHK script by sending messages to its window.
So wrapper.dll needs to be told which window to send messages to do:

global HWnd HWND_AHK
HWnd of AHK script;

wrapper::SetTargetWindow (HWnd W)
{ HWND_AHK = W }
LParam, WParam)
HWND_AHK->SendMessage(WM_PIE_SELECT, Sel, 0)
-1 for Cancel

there are some things I do not know here: how do we choose a message number? Do we just pick a random number and hope it is not already in use, or is there some windows routine to find an empty number and use that?

this one is trivial

TASK 2: write a simple .AHK script that implements this wrapper...

... to spawn (for example) one pie Menu when you depress F1. moving the mouse cursor using the TrackPoint will select some item, releasing F1 will execute that selection. Similarly F2 may show a different pie Menu.

F1:: task3: OnMessage (TPDown)
if Menu_Visible
exit routine

!!!load approp menu into pie Menu object via wrapper

!!!send a left-mouse-down message to the OS

this link shows that a pie menu is spawned by a left click

{note:we could send the click directly as a message}

piemenu.ocx will pick this up and spawn the piemenu

F1 Up:: task3: OnMessage (TPUp)

  • send left-mouse-button up to the OS
piemenu.ocx will pick this up
and kill the piemenu

when something is selected from the piemenu,
the DLL sends a message which we intercept here
on message (PIE_ITEMSELECTED...)
/* depending on the parameters of the message,
take the appropriate action
for example, if the second pie Menu item was
"copy" and that item has just been
selected, we do:

SendKeys "^c"

Task 4a: Extend the pie menu control so that it can show images in addition to text
this will require modifying it the source code for piemenu.ocx
Task 4b: Create a sensible format for representing a piemenu in an AHK script
I want to be able to look inside an A H K script for a pie Menu and see straight away
- what it looks like ( for example what are the items)
- what activates it ( for example TrackPoint down, or F1)
- what action is taken when something is selected ( eg SendKeys "^c")

maybe pie menus should be represented in XML.

this XML could be a long string in a .AHK script or it could be a separate file. In that case the .AHK script would need

#include "mypie.xml"
inserted at the correct location

Write a XML parser either in AHK or in the DLL. Preferably the latter.