A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to disable a keyboards shutdown and sleep keys ?



 
 
Thread Tools Display Modes
  #1  
Old April 26th 20, 02:18 PM posted to microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,113
Default How to disable a keyboards shutdown and sleep keys ?

Hello all,

I've had to get myself a new keyboard, and it got two keys I could do well
without: One that instantly turns my computer off and another which, also
instantly, makes it sleep.

I've been googeling for solutions, but the ones I could find just mitigate
the effects. Like I have disabled the "sleep" mode of my 'puter (blocking
the effect of the "sleep" key) and changed the "power button" setting from
"shut down" to "Ask me what to do" - which /ofcourse/ now also happens when
I push the on/off button on the desktop machine itself. :-(

I've been looking into the "Scancode map" (replacing the "keystrokes" with
something else), but have not been successfull in that regard.

tl;dr: does anyone have an idea how to (programmatically!*) disable the
'power' and 'sleep' keyboard keys ?

*if all else fails I guess I could physically remove those keys, but want to
see if it can be done less destructive.

Regards,
Rudy Wieser


Ads
  #2  
Old April 26th 20, 10:33 PM posted to microsoft.public.windowsxp.general
No_Name
external usenet poster
 
Posts: 602
Default How to disable a keyboards shutdown and sleep keys ?

On Sun, 26 Apr 2020 15:18:44 +0200, "R.Wieser"
wrote:

Hello all,

I've had to get myself a new keyboard, and it got two keys I could do well
without: One that instantly turns my computer off and another which, also
instantly, makes it sleep.

I've been googeling for solutions, but the ones I could find just mitigate
the effects. Like I have disabled the "sleep" mode of my 'puter (blocking
the effect of the "sleep" key) and changed the "power button" setting from
"shut down" to "Ask me what to do" - which /ofcourse/ now also happens when
I push the on/off button on the desktop machine itself. :-(

I've been looking into the "Scancode map" (replacing the "keystrokes" with
something else), but have not been successfull in that regard.

tl;dr: does anyone have an idea how to (programmatically!*) disable the
'power' and 'sleep' keyboard keys ?

*if all else fails I guess I could physically remove those keys, but want to
see if it can be done less destructive.

Regards,
Rudy Wieser


I had a keyboard with the media keys on top that were bothering me and
I opened it up, cut the traces and moved on.
I do agree there must be a software fix tho. Does the key shut you
down in safe mode? That might be a good "cut the problem in half"
strategy. At least you will kn.ow it is an OS thing.

My guess is a registry item.
  #3  
Old April 27th 20, 04:25 AM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 729
Default How to disable a keyboards shutdown and sleep keys ?

On Sun, 26 Apr 2020 15:18:44 +0200, R.Wieser wrote:
Hello all,

I've had to get myself a new keyboard, and it got two keys I could do well
without: One that instantly turns my computer off and another which, also
instantly, makes it sleep.

I've been googeling for solutions, but the ones I could find just mitigate
the effects. Like I have disabled the "sleep" mode of my 'puter (blocking
the effect of the "sleep" key) and changed the "power button" setting from
"shut down" to "Ask me what to do" - which /ofcourse/ now also happens when
I push the on/off button on the desktop machine itself. :-(

I've been looking into the "Scancode map" (replacing the "keystrokes" with
something else), but have not been successfull in that regard.

tl;dr: does anyone have an idea how to (programmatically!*) disable the
'power' and 'sleep' keyboard keys ?

*if all else fails I guess I could physically remove those keys, but want to
see if it can be done less destructive.

Regards,
Rudy Wieser


The keyboars's power management keys aren't disableable or mappable by user
code, because those keys are handled by the kernel before they're being
mapped by the built in keyboard mapper, then passed to applications. The
flow i.e.:

Physical key - Driver stack - Kernel(Handler(Mapper)) - User

One way to disable the Power and Sleep keys, is to reconfigure the system's
global power scheme using WriteGlobalPwrPolicy() function, and change the
PowerButtonAc, PowerButtonDc, SleepButtonAc, and SleepButtonDc fields to a
value which represent a do-nothing.

The alternative way is to create a keyboard filter driver which changes
power management key scan codes before they're handled by the kernel.
  #4  
Old April 27th 20, 04:27 AM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 729
Default How to disable a keyboards shutdown and sleep keys ?

On Mon, 27 Apr 2020 10:25:13 +0700, JJ wrote:

The keyboars's power management keys aren't disableable or mappable by user
code, because those keys are handled by the kernel before they're being
mapped by the built in keyboard mapper, then passed to applications. The
flow i.e.:

Physical key - Driver stack - Kernel(Handler(Mapper)) - User

One way to disable the Power and Sleep keys, is to reconfigure the system's
global power scheme using WriteGlobalPwrPolicy() function, and change the
PowerButtonAc, PowerButtonDc, SleepButtonAc, and SleepButtonDc fields to a
value which represent a do-nothing.

The alternative way is to create a keyboard filter driver which changes
power management key scan codes before they're handled by the kernel.


Oops, I forgot that this isn't a programming newsgroup. In this case, use
the Power Options's Advanced tab to configure what the keyboard Power and
Sleep keys should do.
  #5  
Old April 27th 20, 09:04 AM posted to microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,113
Default How to disable a keyboards shutdown and sleep keys ?

g,

I had a keyboard with the media keys on top that were bothering
me and I opened it up, cut the traces and moved on.


:-) I've been thinking of that too. But being able to do that depends on
how the keyboard is build (I've had some which only had a foil sheet, on
which removing a, damped on, track is ... not that easy. Bypassing a key ?
Near to impossible), I though of popping the keys of, removing the stalks
inside and than put them back with a bit of glue along their rims (no ugly
hole, and with the receiving stalks - still pressable - being covered).

Does the key shut you down in safe mode?


Its shuts down as if I would have pushed the power button on the desktop
tower, or as if I had choosen "turn off" on the Alt-F4 "Turn off computer"
dialog.

At least you will kn.ow it is an OS thing.


It does seem to be, as I could, as described, change the response to that
key being pressed from "instantly" to "ask me" (the alt-F4 shutdown dialog)
in the "Control Panel"

My guess is a registry item.


Likely. The whole problem is that I would like to be able to disable just
the keyboard key, /without/ disabeling the power button on the desktop tower
at the same time.

Regards,
Rudy Wieser


  #6  
Old April 27th 20, 09:19 AM posted to microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,113
Default How to disable a keyboards shutdown and sleep keys ?

JJ,

The keyboars's power management keys aren't disableable or mappable
by user code,


I noticed that when I tried to spot those keystrokes using SetWindowsHookEx
using WH_KEYBOARD_LL. I saw nothing for those keys.

One way to disable the Power and Sleep keys, is to reconfigure the
system's
global power scheme using WriteGlobalPwrPolicy() function, and change the
PowerButtonAc, PowerButtonDc, SleepButtonAc, and SleepButtonDc fields
to a value which represent a do-nothing.


Thats something to look at. Maybe it allows for creating a bit more
fine-grained response (differing between the actual power button and the
keyboard key)

The alternative way is to create a keyboard filter driver which
changes power management key scan codes before they're
handled by the kernel.


I've never made changes /that/ deep in the 'puter. And I'm not at all sure
that I'm even capable of making such a driver ...

Oops, I forgot that this isn't a programming newsgroup. I


Perhaps the "wrong" newsgroup, but the right person. :-)

In this case, use the Power Options's Advanced tab to configure what
the keyboard Power and Sleep keys should do.


:-) Already did that.

Thanks for thr suggestions.

Regards,
Rudy Wieser


  #7  
Old April 27th 20, 03:02 PM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 729
Default How to disable a keyboards shutdown and sleep keys ?

On Mon, 27 Apr 2020 10:19:35 +0200, R.Wieser wrote:

I noticed that when I tried to spot those keystrokes using SetWindowsHookEx
using WH_KEYBOARD_LL. I saw nothing for those keys.


Power management key codes are "eaten" by the kernel. They're not passed to
user code - even if the power policy is configured to not do anything when
one of those keys is pressed.

Under DOS, user programs can hook the keyboard IRQ handler - thus can see
the power management key scancodes - before they're processed by BIOS.
  #8  
Old April 27th 20, 03:25 PM posted to microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,113
Default How to disable a keyboards shutdown and sleep keys ?

JJ,

Power management key codes are "eaten" by the kernel.


It looks like that, yes. I was just assuming (hoping) that the low-level
keyboard hook could at least /see/ those keys (so I knew which ones to try
in the "Scancode map" I spoke of earlier).

Under DOS, user programs can hook the keyboard IRQ handler - thus
can see the power management key scancodes - before they're processed
by BIOS.


Yup, remember that too. Though I normally just hooked the BIOS vector for
them (INT 0x15 IIRC).

Regards


  #9  
Old April 28th 20, 02:59 AM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 729
Default How to disable a keyboards shutdown and sleep keys ?

On Mon, 27 Apr 2020 16:25:10 +0200, R.Wieser wrote:

It looks like that, yes. I was just assuming (hoping) that the low-level
keyboard hook could at least /see/ those keys (so I knew which ones to try
in the "Scancode map" I spoke of earlier).


What's more annoying is that, the kernel ignores injected power management
scancodes when sent using SendInput(). This makes it impossible to have a
custom key or shortcut to act as power management key, unless we manually
call a power action function ourselves.
  #10  
Old April 28th 20, 10:12 AM posted to microsoft.public.windowsxp.general
R.Wieser
external usenet poster
 
Posts: 1,113
Default How to disable a keyboards shutdown and sleep keys ?

JJ,

What's more annoying is that, the kernel ignores injected power
management scancodes when sent using SendInput(). This makes
it impossible to have a custom key or shortcut to act as power
management key,


Yup, I could imagine a use for that. And some very nasty "jokes" on
someone elses 'puter too.

unless we manually call a power action function ourselves.


but as those are available ... :-)

I was thinking of translating those two (three when including the "wake from
sleep" key) to some multimedia keystrokes - which result in calling
predefined programs (browser, email, etc). But nope. :-\

Regards,
Rudy Wieser


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 12:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 PCbanter.
The comments are property of their posters.