Thread: Getting Key state in Dialog based app

  1. #16
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You called the whole accel table (used in Load Accel )

    CM_ACCEL1

    or just the ALT+SPACE combo? (used as a WN_COMMAND case)
    the entry in the Accel table should look like (in VC v6)
    Code:
    CM_ACCEL1                ALT + VK_SPACE                 VIRTKEY
    
    //try this instead of a WPARAM switch
    UINT     idControl=0;
    idControl = GET_WM_COMMAND_ID(wParam, lParam) ;
    switch(idControl)
    Your not using a modal dlg? (will not work as has own msg loop)

    Tested the hAccel != NULL after the LoadAccelTable() call?

    It appears in your resources?
    You included script.rc and resource.h? (you would be getting an error if not, so silly question)

    Try to SetFocus() on some other control, not an edit or default button (or look at subclassing the input to the edit).

    I use accelerators, have tested this particular case, and it an it works, so you have some other error.
    Last edited by novacain; 07-16-2002 at 01:10 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  2. #17
    Unregistered
    Guest
    Novacain,
    Ok, I got it to work with the SW_HIDE, but the key combo for SW_SHOW doesn't work. I take it that's because my app doesn't have the focus, so in order to bring it back I would have to check all keyboard access not just that to my app?? That's a guess. If that's true do you know how I could go about doing that or if it's not the way, do you know what I have to do to get it back??

    -Aaron

  3. #18
    Unregistered
    Guest
    I also want to try and play with SetWindowsHookEx. In order to hook all input on the system, do I have to make a dll? I found an example of SetWindowsHookEx that doesn't use a DLL, but when I try to impliment it, again, only the SW_HIDE is working, but not the restore. I also tried just SW_MINIMIZE and SW_RESTORE, but once the app does not have the focus my hook or accelerator keys do not work. Again, thanks for all your help. I've learned so much on this little app.

    -Aaron

  4. #19
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    A good question is WHY?

    If there is not a good answer then do it a different way or don't do it at all.

    AFAIK the DLL has to be loaded when the OS starts or the hook will not be system wide.

    For some examples using DLL's with a system hook run a search for 'keyloggers'. Fordy has posted links and some code I think that would help.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #20
    Unregistered
    Guest
    Well, what I'm wanting to accomplish is this:
    1) Create an App that encrypts user input with users keys -Done
    2) Use a key combo to hide and unhide the app -Not done

    I guess the system wide hook then is out, since the app would be started on a computer post boot. The app will be running from a floppy drive only, so that only the person who has this app can run it. I guess the question I have then, is there any way, that you can think of, to accomplish the hiding and unhiding of the app??

    -Aaron

  6. #21
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by novacain
    AFAIK the DLL has to be loaded when the OS starts or the hook will not be system wide.
    Actually the systemwide hook can be initiated while the sytem is running.......the system then injects your dll into a process when needed...

    Aaron;

    If I were you I wouldnt try to implement this via a hook..

    When you use a hook, you are adding a layer of code to every app that you are hooking...this does nothing good for the app's efficiency or the system as a whole for that matter...

    Personally I would hide the App and send an icon to the taskbar....that way you are not getting in anyone's way and your app can be unhidden easily.....also you can change the icon to notify the user of things he/she should know.....all without getting in the way

  7. #22
    Unregistered
    Guest
    I just wanted to take this opportunity and say thank you to EVERYONE that helped on this. I learned so much from trying to do this simple little thing. You'll be pleased to know that it works now as I had hoped. I ended up using GetAsyncKeyState and a while loop and as long as a console window wasn't open, it was working great. Thanks again for everyones help on this.

    -Aaron

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input/switch statement issues
    By peanut in forum C Programming
    Replies: 5
    Last Post: 10-27-2006, 02:58 PM
  2. Creating a Dialog Based Application without MFC
    By MitchellH in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2005, 10:02 AM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  4. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM
  5. onKeyDown(), question in dlg based app
    By codewarrior in forum Windows Programming
    Replies: 0
    Last Post: 10-24-2001, 05:26 AM