Recent

Author Topic: [Solved] Program a Keypress  (Read 4790 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
[Solved] Program a Keypress
« on: June 24, 2017, 08:30:22 am »
The page down key on my keyboard doesn't work. I thought it was some mechanical issue so I opened the keyboard. No, the mechanical part was working correctly and nothing I can repair.

I am thinking to write a small utility to simulate page down keypress using shortcut, maybe [shift]+[ctrl]+[d].

I know how to do trayicon but please tell me how to simulate page down keypress using code. I use Linux.
« Last Edit: June 24, 2017, 05:18:06 pm by Handoko »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Program a Keypress
« Reply #1 on: June 24, 2017, 01:36:11 pm »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Program a Keypress
« Reply #2 on: June 24, 2017, 01:39:34 pm »
In theory you can use the package lazmouseandkeyinput.lpk, found at
.../lazarus/components/mouseandkeyinput/

However I could not get the package to compile (using FPC 3.0.2 Lazarus 1.8.0RC2) on a recent 64-bit Linux.
I get a linking error about ld being unable to find -lXtst

I know I used it successfully some time ago, probably Laz 1.6.0 or around that version.
There is an example of simulating both key and mouse input via code in the /example/ subdirectory if you have an older Lazarus setup where it compiles OK.
« Last Edit: June 24, 2017, 03:47:15 pm by howardpc »

Handoko

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
Re: Program a Keypress
« Reply #3 on: June 24, 2017, 04:31:06 pm »
Me too cannot compile using Lazarus 1.6.4 on Linux 64-bit. It only said "Error: Error while linking".

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Program a Keypress
« Reply #4 on: June 24, 2017, 04:40:13 pm »
I'm guessing you guys already know or have installed the xorg devel packages but just in case (and I quote)
Quote
Xtst is provided by xorg and on most Linux distros header files (or development libraries) are provided by devel packages, so you need to install xorg devel packages.
and in this case I guess you need to have both the 64bit and 32bit devel packages installed based on the target of your compilation not the bitness of your IDE (again sorry for being captain obvious).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
Re: Program a Keypress
« Reply #5 on: June 24, 2017, 05:17:09 pm »
Thank you for the info.

I found that we do not have to instal the xorg-dev package (because it will include a lof of other packages that I don't need), I only install libxtst-dev to make the lazmouseandkeyboardinput.lpk and its example to work correctly on my Ubuntu 16.10 64-bit.

 

TinyPortal © 2005-2018