Send Mouse Click?

Linux specific questions.
Post Reply
Wintery
Posts: 1
Joined: Mar 02, 2017 10:50

Send Mouse Click?

Post by Wintery »

My apologies if this has been covered before, but is it possible to send a mouse click with FreeBASIC? I currently have a program reading input from a JoyStick and need to click the mouse at a certain x, y, coordinate. Also I'm on Debian and use Xorg if that helps.

Code: Select all

Screen 12

Dim x As Single
Dim y As Single
Dim buttons As Integer
Dim result As Integer
Dim a As Integer
Dim x_cord As Integer
Dim y_cord As Integer
Dim res As Integer

Const JoystickID = 0

'This line checks to see if the joystick is ok.

If GetJoystick(JoystickID,buttons,x,y) Then
    Print "Joystick doesn't exist or joystick error."
    Print
    Print "Press any key to continue."
    Sleep
    End
End If


Do
    result = GetJoystick(JoystickID,buttons,x,y)

    Locate 1,1
    Print ;"result:";result;" x:" ;x;" y:";y;" Buttons:";buttons,"","",""
   
    'This tests to see which buttons from 1 to 27 are pressed.
    For a = 0 To 26
        If (buttons And (1 Shl a)) Then
            If (a = 4) Then
				res = GetMouse(x_cord, y_cord, , buttons) 'x_cord, and y_cord hold previous coordinates
				SetMouse 320, 240 'this should be set to the location of item to obtain
				
			End If
        End If
    Next a
Loop

St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Send Mouse Click?

Post by St_W »

I don't think gfxlib2 provides any methods to simulate a mouse click.

You'll most likely have to use your operating system's methods to do this. Unfortunately I can't tell how that works for Linux/X11, but these sites look promising:
code: http://www.linuxquestions.org/questions ... ck-594576/
external tool: http://tuxradar.com/content/xdotool-script-your-mouse
Post Reply