' This could be a good trick for cash bars...
' Make your mouse move on the screen
' by Jean CARTIER

DECLARE SUB CheckBox1Click (Sender AS QCHECKBOX)
Declare Sub mouse_event Lib "user32" ALIAS "mouse_event"(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
DECLARE SUB MoveMouse
DECLARE SUB StopMouse

Const MOUSEEVENTF_MOVE = &H1

DIM TimerS AS QTimer

'Test if button is checked (1) or not (-1)
ok = -1

SUB TimerOver
  TimerS.Interval = 100
  MoveMouse
END SUB

CREATE Form AS QFORM
    Caption = "Tremblez"
    Width = 64
    Height = 64
    Center
    CREATE CheckBox1 AS QCHECKBOX
        Caption = "Activer"
        Left = 10
        Top = 10
        Width = 60
        OnClick = CheckBox1Click
    END CREATE
END CREATE

'Insert your initialization code here
TimerS.Interval = 100
TimerS.Enabled = 0 ' True
TimerS.OnTimer = TimerOver 

Form.ShowModal

'--------- Subroutines ---------

SUB CheckBox1Click (Sender AS QCHECKBOX)
    ok = ok*-1
    if ok=-1 then
        TimerS.Enabled = 0 ' True
        Stopmouse
    else
    TimerS.Enabled = 1 ' True
        MoveMouse
    end if
END SUB

SUB MoveMouse
'Random move
    if RND(10)>4 then
        signX = -1
    else
        signX = 1
    end if
    if RND(10)>4 then
        signY = -1
    else
        signY = 1
    end if
    mouse_event(MOUSEEVENTF_MOVE, signX*RND(10), signY*RND(10), cButt, dwEI)
end Sub

SUB StopMouse
    mouse_event(MOUSEEVENTF_MOVE, 0, 0, cButt, dwEI)
end Sub

