View Single Post
Old 01-13-2007, 09:33 AM   #2 (permalink)
zorlac
Creator
 
Join Date: May 2006
Location: Cambridge, UK
Posts: 1,616
zorlac is on a distinguished road
Default

There are three way to do this:

"normal" macros - easiest to create, but least likely to work
"rawkey" macros - will work, but can be fiddly
"predef" macros - the most reliable way of them working.

So, I`ll show the predef macros way of doing it. Firstly, a quick "system keyboard events" primer.

When any key is pressed, it creates two events that the system sees. Firstly, it will see a key-down event when the key is pressed, and secondly it will create a key-up event when the key is released. So, for any key you want to send, the system needs to create two events for it, one down, one up.

This is very important, as if you send a key-down event but forget to also send the key-up event for that key, the keyboard state can get very very upset

Its also very important to know this when you want to be able to press multiple keys at the same time. In your exampel case, you want to press ALT F1. If we break this down into the key events, it looks like this:

ALT key-down
F1 key-down
F1 key-up
ALT key-up

So you are pressing the ALT key down, the the F1 key down, then releasing the F1 key, and finally releasing the ALT key.

Normally yu would enevr have to worry about all this, you just press the keys on the keyboard and it "just happens", but when you need to create these events, you need to understand what is actually going on.

OK, now we have that out of the way, lets show how to create this macro. If you look in the touchbuddy\docs directory for a file called "predef-and-rawkey-reference.html", this shows the list of predef and rawkey events that can be used. In this case, we are just interested in the "PREDEF Name" column.
  • The predef entry for the ALT key is "MENU" or "ALT", so we will stick with "ALT" for now.
  • The predef entry for the F1 key is "F1".

Armed with this, lets create the macros. If these macros are being added to a button type "button" or "toggle", here is what the macro list would look like:

Quote:

macro = predef:ALT, KEYDOWN
macro = predef:F1, KEYDOWN
macro = predef:F1, KEYUP
macro = predef:ALT, KEYUP
As you can see, this is recreating the exact key down and key up events as we worked out above.

I hope this has helped a bit...
__________________


(Setup: XP Pro, classic mode, LinITX 8" touchscreen (Client/Server), 19" touchscreen (Local), latest development version of TouchBuddy)
zorlac is offline   Reply With Quote