Recent

Author Topic: KeyInput problem  (Read 228 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1991
    • Lazarus and Free Pascal italian community
KeyInput problem
« on: July 11, 2019, 09:32:58 am »
Hi guys, I have the following problem on ubuntu 19.04
I have a program that simulates the user iteration with mouse and keyboard (LazMouseInputKey package). Sometimes it happens that I execute commands in succession but they are executed incorrectly. I give an example

KeyInput.Apply ([ssCtrl]);
KeyInput.Press ('V');
KeyInput.UnApply ([ssCtrl]);

KeyInput.Apply ([ssCtrl]);
KeyInput.Press ('A');
KeyInput.UnApply ([ssCtrl]);

KeyInput.Apply ([ssCtrl]);
KeyInput.Press ('C');
KeyInput.UnApply ([ssCtrl]);

This code should paste, select everything and then copy the content. Sometimes it happens that first select everything, then paste and then copy. As if the calls were asynchronous. Does anyone know how to make these calls synchronous?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

sstvmaster

  • Full Member
  • ***
  • Posts: 131
Re: KeyInput problem
« Reply #1 on: July 11, 2019, 10:32:09 am »
You can try to put sleep(10) between the command. I'm not shure how long the Keyboard buffer and the clipboard needs to get/put the data.
Lazarus 2.0.4 x32
Lazarus 2.1.0 Trunk x32
OS Win 7 32bit

jamie

  • Hero Member
  • *****
  • Posts: 2162
Re: KeyInput problem
« Reply #2 on: July 11, 2019, 11:17:14 pm »
maybe a caching issue...

In windows you can insert keys into the keyboard buffer and they come out in sync of course, I don't
know how that would work on the  other targets?

 Try using a Applications.ProcessMessages between.
Number 1 at blue screen app creations!