Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopping repeated mouse-key press
#2
This type set up:

Code: (Select All)
Do 'start of your do loop
    While _MouseInput: Wend 'update the mouse buffer
    MouseDown = _MouseButton(1) 'get the state of the mouse

    Cls
    Print "Mouse clicks:"; TotalClicks 'print the count so we can watch it only increase once per click
    If MouseDown _AndAlso OldMouseUp Then 'the mouse was up, it's now down, we can count it as a click
        TotalClicks = TotalClicks + 1
    End If

    OldMouseUp = _Negate MouseDown 'update the old button status so we can make certain it was up before counting the next click
    _Limit 30
Loop Until _MouseButton(2) _OrElse _KeyHit
System

It really is just that simple.  One variable to track the current button state.  A second variable to record the old button state.

If the old state was UP and the new state is DOWN, it's a click.
IF the old state was DOWN and the new state is DOWN, it's not a click... It would be the button being held down and you could start counting it as a hold event.
IF the old state was UP and the new state is UP, then the mouse button is up and not being pressed.
If the old state was DOWN and the new state is UP, it means the user just released the mouse button.  It's the end of a click or hold state and not the start of one.

Two variables, working together, and you can get all that info if you need it.   In this case, all you're looking for is the simple CLICK result and that's only obtained when the new state is DOWN and the old state was UP previously.
Reply


Messages In This Thread
RE: Stopping repeated mouse-key press - by SMcNeill - 09-02-2025, 02:51 AM
RE: Stopping repeated mouse-key press - by Pete - 09-02-2025, 11:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Any other way to ignore the Alt key using the INKEY method? Pete 24 1,385 12-31-2025, 05:24 PM
Last Post: Pete
  Setting mouse to ignore outside of _NewImage PhilOfPerth 11 712 12-18-2025, 07:20 PM
Last Post: Pete
  Do Loop, Sleep and Mouse Button Dimster 5 583 09-06-2025, 12:57 PM
Last Post: Dimster
  Stopping _SNDPLAYCOPY ?Possible? TerryRitchie 13 2,427 08-08-2024, 01:48 AM
Last Post: TerryRitchie
  Repeating mouse check PhilOfPerth 4 914 07-24-2024, 11:26 PM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: 1 Guest(s)