MauseAndKeyInput lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- RastaManKing · 2024-03-31 07:53 hello! im back to programming from a long rest and im having trouble in a routine, maybe someone can give me a tip on how to achieve my goal. i have a program that executes a procedure inside a TThread.ExecuteInThread(myProcedure); the problem is that in myProcedure i have a KeyInput.Press(VK_SPACE); which brings up CheckSynchronize break in gtk2widgetset.inc i tried setting up a boolean flag, and instead of executing KeyInput in threat, i change boolean flag, then have a repeat..until infinite loop just monitoring the boolean flag and pressing space, but this locks my main form.. which brings me back to main problem.. any ideas how to achieve a key press from a background thread??? ---------------------------------------------------------------------- Thaddy · 2024-03-31 09:48 This interfears with the main thread messageloop. It can probably be done, but with some hacks. The messageloop is started in application.dorun, but that is private I believe. On windows you need no hacks and you can use the SetWindowsHookEx api which can work with a thread. ---------------------------------------------------------------------- RastaManKing · 2024-03-31 20:25 i should of specified, i am using linux.. any ideas on the type of hack that needs to be done for this? point me in the right direction?? ---------------------------------------------------------------------- alpine · 2024-03-31 23:13 Put KeyInput.Press(VK_SPACE) in a separate method PressSpace and call instead Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TThread.Synchronize(TThread.CurrentThread, @PressSpace); ---------------------------------------------------------------------- RastaManKing · 2024-04-01 03:57 Quote from: alpine on April 01, 2024, 01:13:55 amPut KeyInput.Press(VK_SPACE) in a separate method PressSpace and call instead Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TThread.Synchronize(TThread.CurrentThread, @PressSpace); This worked perfect! answer short and to the point, thanks for sharing knowledge! ---------------------------------------------------------------------- alpine · 2024-04-01 08:45 Quote from: RastaManKing on April 01, 2024, 05:57:36 amThis worked perfect! answer short and to the point, thanks for sharing knowledge! No problem. Perhaps you should consider another way for doing this. Is the additional thread really needed?