Life
#22
> @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".


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?
Reply


Messages In This Thread
Life - by james2464 - 08-13-2022, 01:19 AM
RE: Life - by johnno56 - 08-13-2022, 10:36 AM
RE: Life - by James D Jarvis - 08-13-2022, 01:18 PM
RE: Life - by bplus - 08-13-2022, 04:46 PM
RE: Life - by james2464 - 08-13-2022, 05:31 PM
RE: Life - by ChiaPet - 08-14-2022, 12:11 AM
RE: Life - by bplus - 08-13-2022, 10:28 PM
RE: Life - by james2464 - 08-14-2022, 12:36 AM
RE: Life - by ChiaPet - 08-14-2022, 12:41 AM
RE: Life - by james2464 - 08-14-2022, 01:17 AM
RE: Life - by dcromley - 08-14-2022, 02:33 AM
RE: Life - by james2464 - 08-14-2022, 07:21 PM
RE: Life - by james2464 - 08-14-2022, 07:27 PM
RE: Life - by ChiaPet - 08-14-2022, 08:21 PM
RE: Life - by bplus - 08-14-2022, 10:03 PM
RE: Life - by james2464 - 08-15-2022, 12:39 AM
RE: Life - by bplus - 08-15-2022, 01:42 AM
RE: Life - by james2464 - 08-15-2022, 01:27 PM
RE: Life - by Pete - 08-15-2022, 05:25 AM
RE: Life - by james2464 - 08-15-2022, 01:35 PM
RE: Life - by bplus - 08-15-2022, 02:13 PM
RE: Life - by james2464 - 08-16-2022, 01:32 AM
RE: Life - by dcromley - 08-15-2022, 06:49 PM
RE: Life - by james2464 - 08-16-2022, 02:19 AM



Users browsing this thread: 7 Guest(s)