Mouse how long pressed?

Just starting out? Need help? Post your questions and find answers here.
Cyberity
User
User
Posts: 11
Joined: Wed Nov 26, 2014 6:51 pm

Mouse how long pressed?

Post by Cyberity »

Hello !

How can I get mouse press time so I want to know the milisecond of the mouse press time ! Not dll.

I would like a program like: If I press mouse until 1 sec its debug me 1000.
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: Mouse how long pressed?

Post by Bisonte »

An eventloop !

Code: Select all

OpenWindow(0, 100, 100, 200, 200, "Press Mouse in here")

CanvasGadget(0, 20, 20, 160, 160)
StartDrawing(CanvasOutput(0))
Box(0,0,200,200,0)
Box(2,2,186,186, #Red)
StopDrawing()

Repeat
  
  Event = WaitWindowEvent()
  
  If Event = #PB_Event_CloseWindow
    Quit = 1
  EndIf
  
  If Event = #PB_Event_Gadget
    If EventGadget() = 0
      If EventType() = #PB_EventType_LeftButtonDown
        Timer = ElapsedMilliseconds()
      EndIf
      If EventType() = #PB_EventType_LeftButtonUp
        Debug "Leftbutton hold for ca. " + Str(ElapsedMilliseconds() - Timer) + "ms"
      EndIf
    EndIf
    
  EndIf
  
  
Until Quit > 0
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Post Reply