Recent

Author Topic: [SOLVED] MouseWheel on linux  (Read 516 times)

Huhims

  • New member
  • *
  • Posts: 5
[SOLVED] MouseWheel on linux
« on: February 10, 2020, 06:58:16 pm »
how to generate MouseWheel (up/down) to outside of my program?
I can't find any clear examples for linux on internet.

for example:
i want to scroll firefox page with my program.
using timer for example.... ..

what I need to add to my project...
or no need to add anything..?


linux mint 19.3
lazarus 2.0.6
fpc3.0.4
« Last Edit: February 19, 2020, 10:49:22 pm by Huhims »
fpc 2.6.4 | linux mint 17 | lazarus 1.2.6

sash

  • Sr. Member
  • ****
  • Posts: 358
Re: MouseWheel on linux
« Reply #1 on: February 12, 2020, 11:20:54 pm »
I have been done similar thing (but for joysticks) at the low level: basically you have to send messages to /dev/input/your-mouse-device (with uinput). But this probably requires (in addition to your app) root and/or some manipulations with udev rules.

Also, there should be something at x-server level, like X11/Xlib.

Alternatively you could use external application like xdotool. They say it can send events directly to interesting gui process.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

Huhims

  • New member
  • *
  • Posts: 5
Re: MouseWheel on linux
« Reply #2 on: February 17, 2020, 06:57:16 pm »
xdotool not really what I'd like, but it's better than nothing  ::)
txnks bro!

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Arg1 : Pchar = 'click 4';
begin
 SysUtils.ExecuteProcess(('/usr/bin/xdotool'), Arg1, []);
end;

works...
fpc 2.6.4 | linux mint 17 | lazarus 1.2.6

sash

  • Sr. Member
  • ****
  • Posts: 358
Re: MouseWheel on linux
« Reply #3 on: February 18, 2020, 12:42:27 pm »
xdotool not really what I'd like, but it's better than nothing  ::)

Well, (probably) you could improve it, by not using external process: looks like there's `libxdo[-dev]` packages,
which (I think) actually contain needed api, if you know how to use C <-> Pascal bindings:

/usr/include/xdo.h - you need to translate header to Pascal (not all, but just few actually required functions, maybe some dependent structures)
/usr/lib/x86_64-linux-gnu/libxdo.so - you need to link it.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

 

TinyPortal © 2005-2018