Recent

Author Topic: Global hotkey  (Read 537 times)

scribly

  • Jr. Member
  • **
  • Posts: 75
Global hotkey
« on: March 31, 2020, 10:32:25 am »
I'd like to register a hotkey (e.g cmd+alt+Q)" that will do a specific action in my application when pressed, even when my app isn't in the foreground.
Is that possible? I checked out getKeyState but that only gets modifiers

trev

  • Hero Member
  • *****
  • Posts: 648
  • Former Delphi 1-7 and 10.2 User
Re: Global hotkey
« Reply #1 on: March 31, 2020, 12:29:56 pm »
This Apple documentation may be of help.
o Lazarus v2.1.0 r63190, FPC v3.3.1 r44876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r358002
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

scribly

  • Jr. Member
  • **
  • Posts: 75
Re: Global hotkey
« Reply #2 on: March 31, 2020, 11:49:13 pm »
I managed to get it to work with Install(Application)EventHandler, and RegisterEventHotkey

trev

  • Hero Member
  • *****
  • Posts: 648
  • Former Delphi 1-7 and 10.2 User
Re: Global hotkey
« Reply #3 on: April 01, 2020, 02:17:08 am »
I may be wrong, but isn't RegisterEventHotkey from the 32 bit Carbon framework? In which case it will not work after Mojave...
o Lazarus v2.1.0 r63190, FPC v3.3.1 r44876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r358002
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

scribly

  • Jr. Member
  • **
  • Posts: 75
Re: Global hotkey
« Reply #4 on: April 01, 2020, 09:01:24 am »
I'm on catalina and it still works. It's one of the functions that they kept functional in 64-bit
« Last Edit: April 01, 2020, 09:03:49 am by scribly »

trev

  • Hero Member
  • *****
  • Posts: 648
  • Former Delphi 1-7 and 10.2 User
Re: Global hotkey
« Reply #5 on: April 01, 2020, 12:47:45 pm »
Good to know.
o Lazarus v2.1.0 r63190, FPC v3.3.1 r44876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r358002
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

 

TinyPortal © 2005-2018