Recent

Author Topic: (SOLVED) Detect key press when application does not have focus?  (Read 415 times)

spirit517

  • Newbie
  • Posts: 3
(SOLVED) Detect key press when application does not have focus?
« on: November 21, 2019, 10:59:16 pm »
I tought something like this would be trivial, but I am unable to find a solution anyware.

Is there a simple way how to detect the keypress while using some other fullscreen application (so lazarus app does not have focus)?

I found about GetKeyState(VK_Q)=1 in combination with Timer, but that works like toggle.

By toggle i mean that for example this code line in Timer:

Code: Pascal  [Select][+][-]
  1. IF GetKeyState(VK_Q)=1 then Memo1.Lines.Add('Q key has been pressed.');

will write that message every Timer tick, and you have to pres the Q key egain to make it stop. But i just want one time key press.

Does anyone know how to achive this?
Thanks for any help  :)
« Last Edit: November 22, 2019, 09:37:34 pm by spirit517 »

jamie

  • Hero Member
  • *****
  • Posts: 3275
Re: Detect key press when application does not have focus?
« Reply #1 on: November 21, 2019, 11:26:18 pm »
So you want a key logger..

I can do it but no, I won't.

 Sorry.
The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 1612
Re: Detect key press when application does not have focus?
« Reply #2 on: November 21, 2019, 11:28:10 pm »
Hi!

Not an easy thing to do.

We had the discussion some day ago:

https://forum.lazarus.freepascal.org/index.php/topic,47409.0.html

Winni

spirit517

  • Newbie
  • Posts: 3
Re: Detect key press when application does not have focus?
« Reply #3 on: November 21, 2019, 11:40:01 pm »
So you want a key logger..

I can do it but no, I won't.

 Sorry.

So you want a key logger..

I can do it but no, I won't.

 Sorry.

No exactly sure what you want to say there,.. but, i want to know how to callback keypress action to simulate multiple keypresses upon that callback (i already learned how to simulate keypresses). And i want to do this to make universal macos, or quickly imput certain strings (for example SQL templates)... i do not want to hack Donald Trump´s twitter account, if thats what you are concerned about.
I will eventually find out how to do this, with, or without you...

spirit517

  • Newbie
  • Posts: 3
Re: Detect key press when application does not have focus?
« Reply #4 on: November 22, 2019, 09:33:55 pm »
So you want a key logger..

I can do it but no, I won't.

 Sorry.


yeah,.. i dont even have to code it,.. its already done and can be downloaded here on this forum :D
https://forum.lazarus.freepascal.org/index.php?topic=37049.0

Told you i would find out eventually... Your "I can do it but no, I won't." attitude only made me want it more :)

 

TinyPortal © 2005-2018