TrackPie


 * __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**: http://www.piemenu.com/PieMenuDescription.html

and here is the **ActiveX pie Menu object piemenu.ocx** which created them: http://www.piemenus.com/ActiveXPieMenus.html

I want to use this object.

This should give some idea: http://www.autohotkey.com/docs/Tutorial.htm Also have a look at this link: http://www.autohotkey.com/docs/commands.htm As you can see this is a very functional scripting language
 * AutoHotKey (AHK)** is a scripting language optimised for remapping of mouse and keyboard

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. http://www.autohotkey.com/docs/commands/DllCall.htm also it can listen for messages http://www.autohotkey.com/docs/commands/OnMessage.htm


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

the **Properties Events** and **Methods** of **piemenu.ocx** are listed here: http://www.piemenus.com/PieMenuDocumentation.html

this is what **wrapper.dll** needs to do:

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

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:
 * __Events__**

global HWnd HWND_AHK// HWnd of AHK script;

wrapper::SetTargetWindow (HWnd W) { HWND_AHK = W } //LParam, WParam) HWND_AHK->SendMessage(WM_PIE_FOCUSCHANGED, OldSel, NewSel) 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?**
 * http://msdn.microsoft.com/msdnmag/issues/1200/c/**

this one is trivial
 * __Methods__**


 * 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 Menu_Visible=True

!!!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 //http://www.piemenus.com/PieMenuInstructions.html////

{note:we could send the click directly as a message// http://www.autohotkey.com/docs/commands/PostMessage.htm}

piemenu.ocx will pick this up and //spawn// the piemenu }

F1 Up:: //task3: OnMessage (TPUp) {// piemenu.ocx will pick this up and kill //the piemenu }//
 * send left-mouse-button up to the OS

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" }// this will require modifying it the source code for piemenu.ocx 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")
 * Task 4a: Extend the pie menu control so that it can show images in addition to text**
 * Task 4b: Create a sensible format for representing a piemenu in an AHK script**

maybe pie menus should be represented in XML.

http://www.piemenus.com/testpiemenus.xml http://www.piemenus.com/JavaScriptPieMenus.html#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

inserted at the correct location
 * 1) include "mypie.xml"


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