unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
@ 2013-07-04 21:10 Drew Adams
  2013-07-10 17:19 ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2013-07-04 21:10 UTC (permalink / raw)
  To: 14794

At least it does not work as far as I can tell.

emacs -Q    ; but same problem with older Emacs versions

(w32-register-hot-key [M-tab])
(w32-register-hot-key [M-S-tab])

Try C-h k M-TAB.  Try M-TAB.  The key is immediately grabbed by Windows. 



In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-07-01 on LEG570
Bzr revision: 113246 lekktu@gmail.com-20130701165437-ea20s94hqwp3ttaj
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --enable-checking CFLAGS='-O0 -g3'
 CPPFLAGS='-DGLYPH_DEBUG=1 -I/c/usr/include''





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-04 21:10 bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit Drew Adams
@ 2013-07-10 17:19 ` Eli Zaretskii
  0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-10 17:19 UTC (permalink / raw)
  To: Drew Adams; +Cc: 14794

> Date: Thu, 4 Jul 2013 14:10:45 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> 
> At least it does not work as far as I can tell.
> 
> emacs -Q    ; but same problem with older Emacs versions
> 
> (w32-register-hot-key [M-tab])
> (w32-register-hot-key [M-S-tab])
> 
> Try C-h k M-TAB.  Try M-TAB.  The key is immediately grabbed by Windows. 

Because it is not bound to any command.  If you bind it, it will work
as expected.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
       [not found] ` <<83fvvmuyct.fsf@gnu.org>
@ 2013-07-10 22:28   ` Drew Adams
  2013-07-11 16:36     ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2013-07-10 22:28 UTC (permalink / raw)
  To: Eli Zaretskii, Drew Adams; +Cc: 14794

> > emacs -Q    ; but same problem with older Emacs versions
> >
> > (w32-register-hot-key [M-tab])
> > (w32-register-hot-key [M-S-tab])
> >
> > Try C-h k M-TAB.  Try M-TAB.  The key is immediately grabbed by Windows.
> 
> Because it is not bound to any command.  If you bind it, it will work
> as expected.

Nope, not as far as I can see.  Add this to the recipe:

(global-set-key [M-tab] 'forward-char)

Makes no difference.  But perhaps you meant something different?

I'm using Windows 7 64-bit, if that makes a difference.
(And the same code worked fine on Windows XP SP3.)





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-10 22:28   ` Drew Adams
@ 2013-07-11 16:36     ` Eli Zaretskii
  2013-07-12  8:20       ` martin rudalics
  2022-02-20 13:29       ` Lars Ingebrigtsen
  0 siblings, 2 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-11 16:36 UTC (permalink / raw)
  To: Drew Adams; +Cc: 14794

> Date: Wed, 10 Jul 2013 15:28:37 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 14794@debbugs.gnu.org
> 
> > > emacs -Q    ; but same problem with older Emacs versions
> > >
> > > (w32-register-hot-key [M-tab])
> > > (w32-register-hot-key [M-S-tab])
> > >
> > > Try C-h k M-TAB.  Try M-TAB.  The key is immediately grabbed by Windows.
> > 
> > Because it is not bound to any command.  If you bind it, it will work
> > as expected.
> 
> Nope, not as far as I can see.  Add this to the recipe:
> 
> (global-set-key [M-tab] 'forward-char)
> 
> Makes no difference.  But perhaps you meant something different?
> 
> I'm using Windows 7 64-bit, if that makes a difference.
> (And the same code worked fine on Windows XP SP3.)

Turns out it does make a difference.  This documentation page:

  http://msdn.microsoft.com/en-us/library/windows/desktop/ms646309%28v=vs.85%29.aspx

explicitly says that the behavior of the underlying API has changed
since XP: if the hot key is already registered, the API now fails
instead of replacing the old registration with the new.  And Alt+TAB
is hooked by the Windows Explorer.  And indeed, on Windows 7 I see
that the call to RegisterHotKey API consistently fails with an error
code which says "Hot key is already registered".

Unless someone knows a way around this (I searched for it, but didn't
find any solutions, only complaints), I guess this will remain a
"known bug".

Does this work for you with other key combinations, btw?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
       [not found] ` <<8361whuk8c.fsf@gnu.org>
@ 2013-07-11 18:47   ` Drew Adams
  2013-07-11 19:19     ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2013-07-11 18:47 UTC (permalink / raw)
  To: Eli Zaretskii, Drew Adams; +Cc: 14794

> > I'm using Windows 7 64-bit, if that makes a difference.
> > (And the same code worked fine on Windows XP SP3.)
> 
> Turns out it does make a difference.  This documentation page:
> 
>   http://msdn.microsoft.com/en-
> us/library/windows/desktop/ms646309%28v=vs.85%29.aspx
> 
> explicitly says that the behavior of the underlying API has changed
> since XP: if the hot key is already registered, the API now fails
> instead of replacing the old registration with the new.  And Alt+TAB
> is hooked by the Windows Explorer.  And indeed, on Windows 7 I see
> that the call to RegisterHotKey API consistently fails with an error
> code which says "Hot key is already registered".

Ouch.  Awful.  And hard to believe.

> Unless someone knows a way around this (I searched for it, but didn't
> find any solutions, only complaints), I guess this will remain a
> "known bug".
> 
> Does this work for you with other key combinations, btw?

Dunno.  Can you tell me some key combinations to try?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-11 18:47   ` Drew Adams
@ 2013-07-11 19:19     ` Eli Zaretskii
  0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-11 19:19 UTC (permalink / raw)
  To: Drew Adams; +Cc: 14794

> Date: Thu, 11 Jul 2013 11:47:17 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 14794@debbugs.gnu.org
> 
> > Does this work for you with other key combinations, btw?
> 
> Dunno.  Can you tell me some key combinations to try?

How about PrintScreen or S-F10?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
       [not found] ` <<83oba86h0q.fsf@gnu.org>
@ 2013-07-11 21:12   ` Drew Adams
  2013-07-12  6:58     ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2013-07-11 21:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14794

> > > Does this work for you with other key combinations, btw?
> > Dunno.  Can you tell me some key combinations to try?
> 
> How about PrintScreen or S-F10?

I can use S-f10 without any need for `w32-register-hot-key':

(global-set-key [S-f10] 'forward-char)

Doesn't that work for you too?

And I don't know what the Emacs key for PrintScreen is.

(global-set-key [PrintScreen] 'forward-char) and
(global-set-key [printscreen] 'forward-char)

have no effect.  Doing `w32-register-hot-key' for either of them
also has no effect.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-11 21:12   ` Drew Adams
@ 2013-07-12  6:58     ` Eli Zaretskii
  0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-12  6:58 UTC (permalink / raw)
  To: Drew Adams; +Cc: 14794

> Date: Thu, 11 Jul 2013 14:12:32 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 14794@debbugs.gnu.org
> 
> > > > Does this work for you with other key combinations, btw?
> > > Dunno.  Can you tell me some key combinations to try?
> > 
> > How about PrintScreen or S-F10?
> 
> I can use S-f10 without any need for `w32-register-hot-key':
> 
> (global-set-key [S-f10] 'forward-char)
> 
> Doesn't that work for you too?

I didn't try.  You asked for ideas, I gave you some.

> And I don't know what the Emacs key for PrintScreen is.

I think [print], but I don't see that we produce it anywhere.

Maybe try the left/right Win+E key or the Apps key, after setting the
w32-*-modifier variables so as to produce an Emacs modifier from them.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-11 16:36     ` Eli Zaretskii
@ 2013-07-12  8:20       ` martin rudalics
  2013-07-12  8:29         ` Drew Adams
  2013-07-12  8:55         ` Eli Zaretskii
  2022-02-20 13:29       ` Lars Ingebrigtsen
  1 sibling, 2 replies; 16+ messages in thread
From: martin rudalics @ 2013-07-12  8:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14794

 > Turns out it does make a difference.  This documentation page:
 >
 >   http://msdn.microsoft.com/en-us/library/windows/desktop/ms646309%28v=vs.85%29.aspx
 >
 > explicitly says that the behavior of the underlying API has changed
 > since XP: if the hot key is already registered, the API now fails
 > instead of replacing the old registration with the new.  And Alt+TAB
 > is hooked by the Windows Explorer.  And indeed, on Windows 7 I see
 > that the call to RegisterHotKey API consistently fails with an error
 > code which says "Hot key is already registered".
 >
 > Unless someone knows a way around this (I searched for it, but didn't
 > find any solutions, only complaints), I guess this will remain a
 > "known bug".

 From what I read on such systems an application that does not have
registered a key itself is allowed to unregister it only if it is
certified in some way and resides in Program Files.

martin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-12  8:20       ` martin rudalics
@ 2013-07-12  8:29         ` Drew Adams
  2013-07-12  8:55         ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Drew Adams @ 2013-07-12  8:29 UTC (permalink / raw)
  To: martin rudalics, Eli Zaretskii; +Cc: 14794

>  From what I read on such systems an application that does not have
> registered a key itself is allowed to unregister it only if it is
> certified in some way and resides in Program Files.

Wow.  That's really too bad.  Thanks for the info, though.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-12  8:20       ` martin rudalics
  2013-07-12  8:29         ` Drew Adams
@ 2013-07-12  8:55         ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-12  8:55 UTC (permalink / raw)
  To: martin rudalics; +Cc: 14794

> Date: Fri, 12 Jul 2013 10:20:53 +0200
> From: martin rudalics <rudalics@gmx.at>
> CC: Drew Adams <drew.adams@oracle.com>, 14794@debbugs.gnu.org
> 
>  From what I read on such systems an application that does not have
> registered a key itself is allowed to unregister it only if it is
> certified in some way and resides in Program Files.

It's much worse: to unregister a key, you must know its ID (the 2nd
argument to the function).  And how can you that, unless you have
access to the sources of the program that registered the hot key in
the first place?

Moreover, RegisterHotKey can be used so that the hot key is registered
for a specific thread, in which case only that thread can unregister
it.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
       [not found] ` <<83k3kw5kni.fsf@gnu.org>
@ 2013-07-12 16:10   ` Drew Adams
  2013-07-12 18:04     ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2013-07-12 16:10 UTC (permalink / raw)
  To: Eli Zaretskii, martin rudalics; +Cc: 14794

> > And I don't know what the Emacs key for PrintScreen is.
> 
> I think [print], but I don't see that we produce it anywhere.

(global-set-key [print] 'forward-char)
(w32-register-hot-key [print]) ; => 42

Has no effect: The Print Screen key is still not recognized by Emacs.

> Maybe try the left/right Win+E key or the Apps key, after setting the
> w32-*-modifier variables so as to produce an Emacs modifier from them.

Sorry, I don't know what the last clause means.  What w32-* modifier
variables, and how?

But from your and Martin's other replies in this thread it appears that
`w32-register-hot-key' is useless for Windows 7.  Unless I missed
something.  Is there any case at all where it actually will have an
effect?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-12 16:10   ` Drew Adams
@ 2013-07-12 18:04     ` Eli Zaretskii
  0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-12 18:04 UTC (permalink / raw)
  To: Drew Adams; +Cc: 14794

> Date: Fri, 12 Jul 2013 09:10:26 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 14794@debbugs.gnu.org
> 
> > Maybe try the left/right Win+E key or the Apps key, after setting the
> > w32-*-modifier variables so as to produce an Emacs modifier from them.
> 
> Sorry, I don't know what the last clause means.  What w32-* modifier
> variables, and how?

For the Win key, use w32-lwindow-modifier, for the Apps key use the
w32-apps-modifier.  You might need to use these to convert these keys
to something Emacs can use.

> But from your and Martin's other replies in this thread it appears that
> `w32-register-hot-key' is useless for Windows 7.  Unless I missed
> something.  Is there any case at all where it actually will have an
> effect?

I have no idea, I didn't research the issue enough.  This page:

  http://www.sevenforums.com/tutorials/5937-windows-key-shortcuts-enable-disable.html

tells you how to disable the Windows shortcuts, in case you don't have
any use for them outside Emacs.  Perhaps then registering hotkeys will
work on Windows 7.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2013-07-11 16:36     ` Eli Zaretskii
  2013-07-12  8:20       ` martin rudalics
@ 2022-02-20 13:29       ` Lars Ingebrigtsen
  2022-02-20 13:39         ` Eli Zaretskii
  1 sibling, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-20 13:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14794

Eli Zaretskii <eliz@gnu.org> writes:

> Unless someone knows a way around this (I searched for it, but didn't
> find any solutions, only complaints), I guess this will remain a
> "known bug".

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Skimming this bug report, there doesn't seem to be anything to be done
on the Emacs side -- or at least there wasn't eight years ago.

Is this still the case today?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2022-02-20 13:29       ` Lars Ingebrigtsen
@ 2022-02-20 13:39         ` Eli Zaretskii
  2022-02-20 14:04           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2022-02-20 13:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 14794

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Drew Adams <drew.adams@oracle.com>,  14794@debbugs.gnu.org
> Date: Sun, 20 Feb 2022 14:29:00 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Unless someone knows a way around this (I searched for it, but didn't
> > find any solutions, only complaints), I guess this will remain a
> > "known bug".
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> Skimming this bug report, there doesn't seem to be anything to be done
> on the Emacs side -- or at least there wasn't eight years ago.
> 
> Is this still the case today?

I think we have a solution for this since Emacs 26.1.  From NEWS.26:

  ** Intercepting hotkeys on Windows 7 and later now works better.
  The new keyboard hooking code properly grabs system hotkeys such as
  'Win-*' and 'Alt-TAB', in a way that Emacs can get at them before the
  system.  This makes the 'w32-register-hot-key' functionality work
  again on all versions of MS-Windows starting with Windows 7.  On
  Windows NT and later you can now register any hotkey combination.  (On
  Windows 9X, the previous limitations, spelled out in the Emacs manual,
  still apply.)





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit
  2022-02-20 13:39         ` Eli Zaretskii
@ 2022-02-20 14:04           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-20 14:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14794

Eli Zaretskii <eliz@gnu.org> writes:

> I think we have a solution for this since Emacs 26.1.  From NEWS.26:
>
>   ** Intercepting hotkeys on Windows 7 and later now works better.
>   The new keyboard hooking code properly grabs system hotkeys such as
>   'Win-*' and 'Alt-TAB', in a way that Emacs can get at them before the
>   system.  This makes the 'w32-register-hot-key' functionality work
>   again on all versions of MS-Windows starting with Windows 7.  On
>   Windows NT and later you can now register any hotkey combination.  (On
>   Windows 9X, the previous limitations, spelled out in the Emacs manual,
>   still apply.)

Ah, OK, then I guess there's nothing more to do here, and I'm closing
this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-02-20 14:04 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04 21:10 bug#14794: 24.3.50; `w32-register-hot-key' does not work on Windows 7 64-bit Drew Adams
2013-07-10 17:19 ` Eli Zaretskii
     [not found] <<fe76a82d-41dd-4c28-8204-aa7c1e4a2aef@default>
     [not found] ` <<83fvvmuyct.fsf@gnu.org>
2013-07-10 22:28   ` Drew Adams
2013-07-11 16:36     ` Eli Zaretskii
2013-07-12  8:20       ` martin rudalics
2013-07-12  8:29         ` Drew Adams
2013-07-12  8:55         ` Eli Zaretskii
2022-02-20 13:29       ` Lars Ingebrigtsen
2022-02-20 13:39         ` Eli Zaretskii
2022-02-20 14:04           ` Lars Ingebrigtsen
     [not found] <<1bda8371-6234-45f4-a2b8-00ac282f2088@default>
     [not found] ` <<8361whuk8c.fsf@gnu.org>
2013-07-11 18:47   ` Drew Adams
2013-07-11 19:19     ` Eli Zaretskii
     [not found] <<f99844ca-a167-4256-b310-c851f1d84a42@default>
     [not found] ` <<83oba86h0q.fsf@gnu.org>
2013-07-11 21:12   ` Drew Adams
2013-07-12  6:58     ` Eli Zaretskii
     [not found] <<c27d6591-74ce-42dc-96dd-bcb01df42b2c@default>
     [not found] ` <<83k3kw5kni.fsf@gnu.org>
2013-07-12 16:10   ` Drew Adams
2013-07-12 18:04     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).