Screen and Mouse Movement Mods

    Private Const PM_REMOVE = &H1

    Public Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (ByRef lpMsg As MSG, ByVal hwnd As IntPtr, ByVal wMsgFilterMin As Integer, ByVal wMsgFilterMax As Integer, ByVal wRemoveMsg As Integer) As Boolean


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Label5.Text = CBool(bRleaseMouse)

        NotifyIcon1.Icon = IIf(bRleaseMouse, My.Resources.zero, My.Resources.rich_cat_green__28_)

        ' Dim monitor As Screen

        'https://stackoverflow.com/questions/36106563/how-to-place-the-form-on-the-screen-the-mouse-Is-currently-on

        ' Dim CurrentScreen As Screen = Screen.FromPoint(Cursor.Position)

        Dim scr As Screen = Screen.AllScreens.Where(Function(x) x.Bounds.Contains(Control.MousePosition)).Single

        Label2.Text = scr.ToString

        'x+25  x-width

        Label3.Text = "sCurrentDisplay.DeviceName: " & sCurrentDisplay.DeviceName

        Label4.Text = "scr.DeviceName " & scr.DeviceName

        If bRleaseMouse Or Not bOn Then

            Cursor.Clip = Rectangle.Empty

            bRleaseMouse = False

        Else

            Cursor.Clip = scr.Bounds   'Lock the mouse to the screen that it's on 

        End If

        Label1.Text = "Mouse Cursor Location : " & mousepos.X & "/" & My.Computer.Screen.Bounds.Size.Width & " x " & mousepos.Y & " / " & My.Computer.Screen.Bounds.Size.Height

        'bRleaseMouse = False

        bRleaseMouse = False

    End Sub

    Public Structure MSG

        Public hwnd As IntPtr

        Public message As Integer

        Public wParam As IntPtr

        Public lparam As IntPtr

        Public time As Integer

        Public point As Point

    End Structure

    'https://bytes.com/topic/visual-basic-net/answers/755785-clearing-keyboard-buffer

    Public Sub Flush()

        Dim msgToss As MSG

        Do While PeekMessage(msgToss, Me.Handle, 0, 0, PM_REMOVE) = True

            Debug.Print(msgToss.message)

        Loop

    End Sub