Results 1 to 4 of 4

Thread: keyboard hooks

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    keyboard hooks

    Hello

    I've installed a keyboard hook, and am trying to log the information that it turns out.

    I know the hook is working, as it outputs to a file, howver i also want it to push some info onto a vector, howver it seems to write to the file, but not always push onto the vector!?

    Are there any reasons why it should do one and not both?

    heres the keyboardproc.....any ideas?

    LRESULT STDCALL KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
    {
    TypeInfo newTypeInfo;
    newTypeInfo.setup();
    if( lParam < 0 ) //UP
    {
    //find matching up keystroke
    for(int c = 0; c < wit.size(); c++)
    {
    if(wit[c].key == wParam && wit[c].up == NULL)
    {
    //insert time if time is NULL
    wit[c].up = atof(TimerRet());
    c = wit.size();
    }
    }
    fprintf(pKEYBOARD, "KeyUP:,%d,%s,%s\n",wParam, TimerRet(),KeyType(wParam));
    SampleCounter++;

    }
    else //DOWN
    {
    newTypeInfo.down = atof(TimerRet());
    newTypeInfo.key = wParam;
    wit.push_back(newTypeInfo);
    fprintf(pKEYBOARD, "KeyDOWN:,%d,%s,%s\n",wParam, TimerRet(),KeyType(wParam));
    fprintf(pWIT, "%s", KeyType(wParam));
    }



    //Pass message on to the next hook in the chain
    return CallNextHookEx(hKBHook, code, wParam, lParam);
    }


    Cheers in advance

    Andy

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Is wit a vector from STL?

    Whatever, the problem might be one of memory. Since the hook is in a dll, it operates in various memory areas. There is a special _declspec you can use to make all mappings of the dll use the same memory.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222
    wit is a vector from the stl, and is stored ina peice of shared memory, would this not mean that it is shared across all instances of the dll?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    yeah, then I don't know.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width