08-15-2022, 06:49 PM
(This post was last modified: 08-19-2022, 05:29 PM by dcromley.
Edit Reason: slight improvements
)
> @james2464
> It seems tricky to be able to 'capture' a right-click.
This may be helpful -- it is a program that just draws random points, but also checks the left and right mouse buttons and draws colored lines. It checks for the down-edges (clicks) and up-edges (ends).
> Also, what sort of delay/wait method would be appropriate?
You may already have this answered, but are you interested in "repeat" clicks? Like repeating keys? I have a version that adds that, using "TIMER(.001)"
Anyway, thanks for "Life".
> It seems tricky to be able to 'capture' a right-click.
This may be helpful -- it is a program that just draws random points, but also checks the left and right mouse buttons and draws colored lines. It checks for the down-edges (clicks) and up-edges (ends).
> Also, what sort of delay/wait method would be appropriate?
You may already have this answered, but are you interested in "repeat" clicks? Like repeating keys? I have a version that adds that, using "TIMER(.001)"
Anyway, thanks for "Life".
Code: (Select All)
_Title "MOUSECKMIN.bas" ' dcromley
Option _Explicit
Dim Shared mx, my, m1Clk, m1Dn, m1End, m2Clk, m2Dn, m2End ' for mouse
Screen _NewImage(1024, 768, 256)
Dim nloop, x1, y1, x2, y2
Locate 8, 2: Print "Drag left or right mouse"
Locate 9, 2: Print "ESC to exit"
Do
_Limit 1000 '
nloop = nloop + 1
' -- main job is to just set/reset points
x1 = Int(Rnd * 100): y1 = Int(Rnd * 100)
If nloop Mod 2 = 1 Then PSet (x1, y1), 0 Else PSet (x1, y1), 15 ' alternate black/white
' -- now check Mouse
MouseCk
' button 1 Click, Down, End
If m1Clk Then Circle (mx, my), 4, 12: Paint (mx, my), 12
If m1Dn Then PSet (mx, my), 12
If m1End Then Circle (mx, my), 4, 12
' button 2 Click, Down, End
If m2Clk Then Circle (mx, my), 4, 10: Paint (mx, my), 10
If m2Dn Then PSet (mx, my), 10
If m2End Then Circle (mx, my), 4, 10
Loop Until InKey$ = Chr$(27)
System
Sub MouseCk () ' get mouse info
Static m1Prev, m2Prev ' for getting edges (Clk and End)
m1Clk = 0: m1End = 0: m2Clk = 0: m2End = 0
While _MouseInput: Wend ' clear
mx = _MouseX: my = _MouseY
m1Dn = _MouseButton(1) ' button 1 processing
If m1Dn Then ' Btn 1 down
If Not m1Prev Then m1Clk = -1 ' if down-edge, then it is a Click
Else ' Btn 1 up
If m1Prev Then m1End = -1 ' if up-edge, then it is the End
End If
m2Dn = _MouseButton(2) ' button 2 processing
If m2Dn Then ' Btn 2 down
If Not m2Prev Then m2Clk = -1 ' if down-edge, then it is a Click
Else ' Btn 2 up
If m2Prev Then m2End = -1 ' if up-edge, then it is the End
End If
m1Prev = m1Dn: m2Prev = m2Dn ' for next time
End Sub
___________________________________________________________________________________
I am mostly grateful for the people who came before me. Will the people after me be grateful for me?
I am mostly grateful for the people who came before me. Will the people after me be grateful for me?