Recent

Author Topic: Global hotkeys Linux/Windows/Osx  (Read 6867 times)

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Global hotkeys Linux/Windows/Osx
« on: March 13, 2011, 08:12:11 am »
Hi I cant find anything relating to coding for global hotkeys in Lazarus.
Its necessary to be able to hotkey my tray program to bring it in front of other running programs.
I've done it before in Delphi/Windows.
Appreciate any info/url that can get me started thanks vm.
Alistair.
« Last Edit: March 14, 2011, 03:59:51 am by AlistairG »
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: [solved - weak] Global hotkeys Linux/Windows/Osx
« Reply #1 on: March 13, 2011, 09:32:55 pm »
My research shows that due to various platforms different methods for handling messages that its too difficult:
http://wiki.freepascal.org/LCL_Messages
and
http://www.freepascal.org/docs-html/ref/refsu28.html
I am surprised at this though, as even at the lowest level of assembler and 8051 microprocessors all of them generate an interrupt which can be hooked into.

What I have done to handle keyboard events is to include in my system timer which was .5 sec and reduce resolution to .25s scanning for predefined keyboard combination each time

BUT this only works when the mainform is in front. Keys are not scanned by the program if the mainform is hidden!
« Last Edit: March 14, 2011, 04:01:26 am by AlistairG »
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: [solved - weak] Global hotkeys Linux/Windows/Osx
« Reply #2 on: March 13, 2011, 10:49:25 pm »
Do your keyboard shorcuts works on Linux and Windows?
I'm interested in such a multiplatform solution :P
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Global hotkeys Linux/Windows/Osx
« Reply #3 on: March 13, 2011, 11:08:51 pm »
Do your keyboard shorcuts works on Linux and Windows?
I'm interested in such a multiplatform solution :P
The methods I described do not work when the mainform is hidden. Of course, timer works when mainform is hidden. I thought that getkeystate would work within the timer loop also; but I am wrong, so still working on a satisfactory solution.
Cheers,
Alistair.
« Last Edit: March 14, 2011, 07:38:04 pm by AlistairG »
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

 

TinyPortal © 2005-2018