zoukankan      html  css  js  c++  java
  • 一些控制鼠标的例子!

     1.模拟鼠标击键过程 
    '声明:
    Option Explicit
     Private Declare Sub mouse_event Lib "user32" ( ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long )

    '对变量的定义
    Const MOUSEEVENTF_LEFTDOWN = &H2
    Const MOUSEEVENTF_LEFTUP = &H4
    Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Const MOUSEEVENTF_MIDDLEUP = &H40
    Const MOUSEEVENTF_MOVE = &H1
    Const MOUSEEVENTF_ABSOLUTE = &H8000
    Const MOUSEEVENTF_RIGHTDOWN = &H8
    Const MOUSEEVENTF_RIGHTUP = &H10

     '这里是 鼠标左键按下 和松开两个事件的组合即一次单击
     mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

     '模拟鼠标右键单击事件
     mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0

     '两次连续的鼠标左键单击事件 构成一次鼠标双击事件
     mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
     mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

    2.模拟鼠标显示.隐藏 
    隐藏/显示鼠标.

    Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

    'forml中函数如下
    '隐藏鼠标(需要事件击活,比如窗体事件等)
    ShowCursor False
    '显示鼠标(需要事件击活,比如窗体事件等)
    ShowCursor True
     3.定位鼠标,使之不能移动 
    定位鼠标。

    Type rect
     sbleft As Long
     sbtop As Long
     sbright As Long
     sbbottom As Long
    End Type

    Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long


    '鼠标定位
    Private Sub Form_Load()
    '定位鼠标
     Dim x As Long, y As Long
     Dim newrect As rect
     x& = Screen.TwipsPerPixelX
     y& = Screen.TwipsPerPixelY
     
     With newrect '鼠标只能在500,500-500,500这个范围内移动,如果四个数一样也可以说锁定鼠标了.如果加在记时器里的话就移动不了啦.
     .sbleft = 500
     .sbtop = 500
     .sbright = 500
     .sbbottom = 500
     End With
     
     ClipCursor newrect
    如果鼠标被锁定,不能恢复怎么办?不用担心.看如下代码.
    '使鼠标恢复(设定一个事件.才好击活这个代码.)
     Dim newrect As rect
     With newrect '这样鼠标又可以在0,0-屏幕的最右角,屏幕的最右下脚移动了
     .sbleft = 0
     .sbtop = 0
     .sbright = Screen.Width / Screen.TwipsPerPixelX
     .sbbottom = Screen.Height / Screen.TwipsPerPixelY
     End With
     
     ClipCursor newrect
     End Sub

    2.模拟鼠标显示.隐藏 
    隐藏/显示鼠标.

    Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

    'forml中函数如下
    '隐藏鼠标(需要事件击活,比如窗体事件等)
    ShowCursor False
    '显示鼠标(需要事件击活,比如窗体事件等)
    ShowCursor True
     3.定位鼠标,使之不能移动 
    定位鼠标。

    Type rect
     sbleft As Long
     sbtop As Long
     sbright As Long
     sbbottom As Long
    End Type

    Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long


    '鼠标定位
    Private Sub Form_Load()
    '定位鼠标
     Dim x As Long, y As Long
     Dim newrect As rect
     x& = Screen.TwipsPerPixelX
     y& = Screen.TwipsPerPixelY
     
     With newrect '鼠标只能在500,500-500,500这个范围内移动,如果四个数一样也可以说锁定鼠标了.如果加在记时器里的话就移动不了啦.
     .sbleft = 500
     .sbtop = 500
     .sbright = 500
     .sbbottom = 500
     End With
     
     ClipCursor newrect
    如果鼠标被锁定,不能恢复怎么办?不用担心.看如下代码.
    '使鼠标恢复(设定一个事件.才好击活这个代码.)
     Dim newrect As rect
     With newrect '这样鼠标又可以在0,0-屏幕的最右角,屏幕的最右下脚移动了
     .sbleft = 0
     .sbtop = 0
     .sbright = Screen.Width / Screen.TwipsPerPixelX
     .sbbottom = Screen.Height / Screen.TwipsPerPixelY
     End With
     
     ClipCursor newrect
     End Sub

  • 相关阅读:
    python 读fnl数据
    全面学习ORACLE Scheduler特性(12)使用Windows和Window Groups
    全面学习ORACLE Scheduler特性(11)使用Job Classes
    全面学习ORACLE Scheduler特性(9)创建Chains
    全面学习ORACLE Scheduler特性(10)管理Chains
    全面学习ORACLE Scheduler特性(8)Application抛出的Events
    全面学习ORACLE Scheduler特性(6)设置Repeat Interval参数
    全面学习ORACLE Scheduler特性(7)Scheduler抛出的Events
    全面学习ORACLE Scheduler特性(5)Schedules调度Programs执行的Jobs
    全面学习ORACLE Scheduler特性(4)创建和管理Schedule
  • 原文地址:https://www.cnblogs.com/xxaxx/p/1655474.html
Copyright © 2011-2022 走看看