Gesture() API for Windows 7? RRS feed

  • Question

  • I am trying to simulate multi-touch by calling SendMessage(WM_GESTURE, ...), but having problems getting it to work.

    I see there is a GetGestureInfo() function for converting the HGESTUREINFO to PGESTUREINFO, but there does not seem to be a SetGestureInfo() to do the reverse conversion.

    In MSDN I found a Gesture() function which seems to do exactly what I need, but it appears to only be available for Windows CE for some reason:


    Does anyone know if it is possible to simulate gestures by sending WM_GESTURE messages?

    I have heard alot about the MultiTouchVista project, but after looking through the code could not find anything that does this. If there is code in that project that does this, please let me know what function it resides in.


    Friday, August 20, 2010 2:50 PM

All replies

  • Are you trying to test your application or are you trying to pump gesture messages to another application?  If it's just within your application, you could populate a GESTUREINFO structure with your test values and the pass it to your function that uses gestures in a way that can be substituted with GetGestureInfo...

    Also, if you are trying to develop a multitouch application, you might instead want to consider using the manipulation processor and the WM_TOUCH message.  The following code shows how I have used mouse data to simulate touch input to the manipulation processor:

    VOID Drawable::FillInputData(TOUCHINPUT* inData, DWORD cursor, DWORD eType, DWORD time, int x, int y){
      inData->dwID = cursor;
      inData->dwFlags = eType;
      inData->dwTime = time;
      inData->x = x;
      inData->y = y;
    BOOL Drawable::ProcessMouseData(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
      TOUCHINPUT tInput;
      BOOL fContinue = true;
      if (this->getCursorID() == MOUSE_CURSOR_ID){     
        switch (msg){
          case WM_LBUTTONDOWN:
            FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_DOWN, (DWORD)GetMessageTime(),LOWORD(lParam) * 100,HIWORD(lParam) * 100);
            fContinue = ProcessInputs(hWnd, 1, &tInput, 0);
          case WM_MOUSEMOVE:
            if(LOWORD(wParam) == MK_LBUTTON){
              FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_MOVE, (DWORD)GetMessageTime(),LOWORD(lParam) * 100, HIWORD(lParam) * 100);
              fContinue = ProcessInputs(hWnd, 1, &tInput, 0);
          case WM_LBUTTONUP:
            FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_UP, (DWORD)GetMessageTime(),LOWORD(lParam) * 100, HIWORD(lParam) * 100);      
            fContinue = ProcessInputs(hWnd, 1, &tInput, 0);
      return fContinue;

    Hope that helps!


    Friday, August 20, 2010 4:48 PM
  • gclassy,

    Thanks for the response. I am trying to simulate higher-level touch gestures and not dealing with low-level WM_TOUCH events.  The method of using mouse data to simulate gestures will not work because there are some gestures (zoom, etc.) which cannot be done the same way with the mouse. I need to be able to make an application window think it is receiving gestures from a multi-touch screen (GID_ZOOM, etc.) , which is why I am trying to send WM_GESTURE messages.

    If you can think of any other way to do this please let me know.


    Monday, August 23, 2010 2:23 PM