Solved

How to trap Keystrokes like Ctrl-A-C

Posted on 1997-09-22
1
1,046 Views
Last Modified: 2013-11-19
I'm trapping WM_KEYDOWN messages in PreTranslate Message and
want to figure out if the user is pressing more than one
Key in addition to the Ctrl Key. What is the best way to do
that? Presently, I have something like :

switch(pMsg->message)
{
 case WM_SYSKEYDOWN:
 case WM_KEYDOWN:
      if (pMsg->wParam >= 65 && pMsg->wParam <= 97) {
            if (GetKeyState(VK_SHIFT) || GetKeyState(VK_CAPITAL)) TRACE("GOT Uppercase %c\n",pMsg->wParam);
            if (GetKeyState(VK_CONTROL)) TRACE("GOT Ctrl %c\n",pMsg->wParam);
            if (GetKeyState(VK_MENU)) TRACE("Got Alt %c\n",pMsg->wParam);
      }
}


This is good for one Key, say Ctrl-A, How can I trap
something like say Ctrl-A-C.

Also, some characters like '[' & ']' have Virtual codes
which don't map to their ASCII equivalents. For e.g.
for ']' I get virtual code 221 in the WM_KEYDOWN message
and ASCII 93 in the WM_CHAR message. How can I perform
this conversion in the WM_KEYDOWN message?


0
Comment
Question by:bola053097
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 120 total points
ID: 1306716
Use GetKeyboardState. This returns an array, indexed by the key and the value is determined by whether the key is down or not. Take a look at the online help for more information about GetKeyboardState().

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 85
fizzArray  challenge 1 109
no14 challenge 14 73
Line meaning 9 89
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question