question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to handle `WM_HOTKEY` message?

See original GitHub issue

I wan’t to call RegisterHotKey to reigster global hotkey, but i don’t know how to handle WM_HOTKEY in winui3, where is windows message loop ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
castorixcommented, Aug 15, 2023

m_hwndHotkey = ::CreateWindow(wndClass.lpszClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, wndClass.hInstance, this);

So you’re not hooking the WinUI3 window’s message loop, you’re just creating an additional (invisible) window. Hmmm.

Actually maybe this is sub-classing. Better just copy paste.

I had posted a sample in C#, using standard subclassing : https://github.com/castorix/WinUI3_DesktopDuplication/blob/master/MainWindow.xaml.cs

0reactions
tom-huntingtoncommented, Aug 15, 2023

m_hwndHotkey = ::CreateWindow(wndClass.lpszClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, wndClass.hInstance, this);

So you’re not hooking the WinUI3 window’s message loop, you’re just creating an additional (invisible) window. Hmmm.

Actually maybe this is sub-classing. Better just copy paste.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle Windows messages (WM_HOTKEY)?
procedure TMyForm.WMHotKey(var Message: TMessage); begin ShowMessage('Hotkey pressed.'); end; I tried using SC_HOTKEY instead of WM_HOTKEY.
Read more >
WM_HOTKEY message (Winuser.h) - Win32 apps
Retrieves a handle to the window that contains the specified point.
Read more >
How to use Global HotKeys on Windows - Lost in Details
So our implementation of the Windows Procedure will only handle WM_HOTKEY messages and fire a HotKeyPressed event if that is the case and...
Read more >
c++ - Can WM_HOTKEY be used to simulate hotkey events?
Yes, thanks for correcting, the hotkey should be in lParam in terms of WM_HOTKEY message. For wParam, Ill give Spy++ a go. Now...
Read more >
WM_HOTKEY Message - General and Gameplay ...
I'm calling this: RegisterHotKey(hwnd,0,MOD_CONTROL|MOD_ALT,0x44); and when the user presses Ctrl-Alt-D, I process this: case WM_HOTKEY: switch(wParam) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found