views:

597

answers:

1

I have a multitoch-enabled tablet PC running Windows 7.

However, when using the stylus pen and getting too far away from the display, I often accidently hit it with my fingers which causes unwanted mouse-clicks.

The solution is navigating to "Control Panel - Pen- and Finger Input - Finger Input" and deactivate the checkbox "Use the finger as an input device" (all titles translated so they might be different on an English windows).

Now I am wondering whether I can do this programatically, too, so I would be able to write a little tray app for this.

I tried using Process Monitor to find out registry keys, however, I did not find one which really shows the same effect as the checkbox.

Does anyone know how to access this property (without using UI-Automation)?

Cheers
winSharp93

+2  A: 

This can be done by manipulating the MICROSOFT_TABLETPENSERVICE_PROPERTY flag set.

#include <tpcshrd.h>  

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)  {   
    const DWORD_PTR dwHwndTabletProperty =  
        TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click) gesture  
        TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves)  
        TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button down  
        TABLET_DISABLE_FLICKS; // disables pen flicks (back, forward, drag down, drag up)   
    ATOM atom = GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY);   
    SetProp(hWnd, MICROSOFT_TABLETPENSERVICE_PROPERTY, reinterpret_cast (dwHwndTabletProperty));  
    GlobalDeleteAtom(atom); 
}

(I am not taking the credits for this one, soure)

The important parameter is the hWnd handle you pass to SetProp. GetDesktopWindow returns the handle of the desktop window. Setting this for the desktop window should deactivate it for all windows on the desktop and the desktop itself. Note however that this won't be a constant change (reboot will undo it).

Possible values you can use are

#define TABLET_DISABLE_PRESSANDHOLD        0x00000001
#define TABLET_DISABLE_PENTAPFEEDBACK      0x00000008
#define TABLET_DISABLE_PENBARRELFEEDBACK   0x00000010
#define TABLET_DISABLE_TOUCHUIFORCEON      0x00000100
#define TABLET_DISABLE_TOUCHUIFORCEOFF     0x00000200
#define TABLET_DISABLE_TOUCHSWITCH         0x00008000
#define TABLET_DISABLE_FLICKS              0x00010000
#define TABLET_ENABLE_FLICKSONCONTEXT      0x00020000
#define TABLET_ENABLE_FLICKLEARNINGMODE    0x00040000
#define TABLET_DISABLE_SMOOTHSCROLLING     0x00080000
#define TABLET_DISABLE_FLICKFALLBACKKEYS   0x00100000
#define TABLET_ENABLE_MULTITOUCHDATA       0x01000000

( http://msdn.microsoft.com/en-us/library/bb969148%28VS.85%29.aspx )

Mef
Thanks for your response. <br />However, I found no possibility to realize the behavior I want using *SetProp*. Two problems: Applying this to the desktop handle showed no effect in other windows. The second problem I ran into is even worse: Those flags affect **both pen and finger (touch) input** - and that's not what I want to; I want to switch between them.
winSharp93
The second problem might occur because I included both pen and touch in my example - just use the params you want to manipulate ;-)
Mef
Well - which values then only affect finger-input? On a single window I tried TABLET_DISABLE_PRESSANDHOLD (easy to check) and TABLET_DISABLE_TOUCHSWITCH - both show effects one pen / stylus as well as finger / touch input. TOUCHUIFORCEON/OFF do not seem to influence the behavior of the window to touch/stylus input.
winSharp93
If the PENXXX and TOUCHXXX constants don't make a difference, then I give up ;-) Unfortunately I can't test anything myself, I don't have a touch-enabled device.
Mef
Well - it seems you will have to give up - they actually affect both stylus as well as finger input. It seems they are named quite confusing...
winSharp93