Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disable windows keys

Posted on 1999-09-11
12
Medium Priority
?
230 Views
Last Modified: 2013-12-03
I want to write a program to intercept windows keypresses and prevent that keypress from being detected by windows. Also, I would like to remap that keypress to another key. My biggest problem is that this must also work for the three windows specific keys (and they're causing me much trouble). If anyone know how to do this it would be much appreciated...

Regards,
  Michael
0
Comment
Question by:carceri
[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
12 Comments
 
LVL 6

Expert Comment

by:WxW
ID: 2039064
You need to install a message hook . SetWindowsHookEx() with WH_CALLWNDPROC or WH_GETMESSAGE . Then you can decide if you want to pass any WM_KEYDOWN , WM_CHAR , or WM_SYSKEYDOWN to the application.
0
 

Author Comment

by:carceri
ID: 2039235
And if I don't want to pass any of those to the application, how can I tell it not to. By the return value of the function?

Regards,
  Michael
0
 

Author Comment

by:carceri
ID: 2039238
And if I don't want to pass any of those to the application, how can I tell it not to. By the return value of the function?

Regards,
  Michael
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:carceri
ID: 2039243
Hmmm, if you just post a comment without checking any of the boxes it defaults to accept the answer (or so it appers :-)

And if you reload the page, it posts the comment again...
0
 
LVL 6

Expert Comment

by:WxW
ID: 2039374
Sorry - I thought that you could prevent the message from being sent . You can discard my answer =(
0
 

Author Comment

by:carceri
ID: 2039542
I can prevent "normal" keystrokes from being sent, but somehow I can't just block the windows keys. I can prevent all the system keys, but there apper to be special rules for the windows keys. Sorry if I wasn't clear enough in my question

Regards,
  Michael
0
 
LVL 3

Expert Comment

by:jsakhtar
ID: 2040019
What keys do you want to prevent exactly?

Ctrl-Esc, Alt-Tab, Ctrl-Shift-Esc??
0
 

Author Comment

by:carceri
ID: 2040033
I want to prevent the three windows keys from working. They are very annoying and I always hit them at the wrong time. I would also like to remap these keys to something else...

I can of cause block all HCBT_SYSCOMMAND keys, but then I also block keys like Ctrl-Esc etc... and that's not what I want.

The win32.hlp file says that if I place a WH_KEYBOARD and a WH_CBT hook, I should be able to (when the code in the WH_CBT procedure is HCBT_KEYSKIPPED) edit items in the system message queue (eg remove the keys I don't want processed or/and insert another key) but I never get the HCBT_KEYSKIPPED code in WH_CBT procedure...

If I can get this code, I think that I can disable these keys...
0
 

Author Comment

by:carceri
ID: 2040044
Hmm... I was wrong... being able to trap the key in the CBTHookProc won't help me discard or remap the message:

function CBTHookProc(nCode: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT stdcall;
begin
  if (nCode = HCBT_KEYSKIPPED) and ((WPARAM = 91) or (WPARAM = 92) or (WPARAM = 93)) then
  Result := 1 else Result := CallNextHookEx(hCBTHook, nCode, wParam, lParam);
end;

A return value different from 0 should make it clear that the message should not be processed, but it still is. If I remove the else part windows locks up, since no messages get processed (it stops all messages comming it's way)

I can't see why the above code won't work...

btw... WPARAM 91 92 and 93 are the three windows keys
0
 
LVL 2

Expert Comment

by:cessi0g
ID: 2041617
To REALLY intercept system keystrokes YOU NEED a VxD.
There's no other way to do that.

Many people asked the same question.

Look my answer at http://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=10045464 . It could help you.

Regards,
Jorge
0
 
LVL 1

Accepted Solution

by:
chrismal earned 200 total points
ID: 2056228
Michael,
To remap the Windows-Keys you are going to need a VxD that hooks these keys in VKD as hotkeys maybe(other ways too).  But if you are looking to is just disable these keys I can suggest a few way.

1. If you just want to disable the keys you can directly do this in Windows Control Panel.  If you need more info I can do a little digging myself but I think it's in Windows Help files.

2. You can use WindowsHookEx to trap most of the keys but it will not work for Ctrl+Esc and Alt+Tab and equivalent Windows-Keys. To block them also from reaching their destination your application has to register as a ScreenSaver.  You can user keybd_event() function to simlulate key presses if you like.
0
 

Author Comment

by:carceri
ID: 2056358
I am looking into the VxD issue. Disableling them for a start would do, but I would like to remap them to other keys, like you can easily do in Linux.

I can trap the keys, but not prevent them from reaching their destination. To register as a screen saver works, but also blocks eg Ctrl-Esc and that's not what I want.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

730 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