unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ImgList, ComCtrls, ExtCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Timer1: TTimer;

Button6: TButton;

Label1: TLabel;

RadioButton1: TRadioButton;

RadioButton2: TRadioButton;

Button5: TButton;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

procedure Button4Click(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var  pt: TPoint;

begin

//模拟左键单击

If RadioButton1.Checked Then

Begin

pt:= Edit1.ClientToScreen( Point(4,4));   //鼠标定位

SetCursorPos( pt.x, pt.y );

mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );

mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );

end;

//模拟右键单击

If RadioButton2.Checked Then

Begin

pt:= Edit1.ClientToScreen(Point(4,4));       //鼠标定位

SetCursorPos( pt.x, pt.y );

mouse_event( MOUSEEVENTF_RightDOWN, 0, 0, 0, 0 );

mouse_event( MOUSEEVENTF_RightUP, 0, 0, 0, 0 );

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

var btn3Rect: TRect;

begin

btn3Rect := Button3.BoundsRect;

MapWindowPoints(handle,0, btn3Rect, 2);  // 坐标换算

ClipCursor(@btn3Rect);                   // 限制鼠标移动区域

end;

procedure TForm1.Button3Click(Sender: TObject);

var btScreen: TRect;

begin

btScreen := Rect(0, 0, Screen.Width, Screen.Height);

ClipCursor(@btScreen);       //解琐,使鼠标在整个屏幕有效

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

cursor:=crNone;   //2秒钟没有移动鼠标就在当前窗体隐藏鼠标

end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

begin

if Timer1.Enabled=True  then //判断定时器是否打开

begin                        //如打开,则重新开始计时

Timer1.Enabled:=False;

Timer1.Enabled:=True;

end;

cursor:=crDefault;          //鼠标移动时,改变光标类型为缺省类型

end;

procedure TForm1.Button6Click(Sender: TObject);

var mouseinfo:string;

begin

//检测是否安装了鼠标

If (GetSystemMetrics(SM_MOUSEPRESENT)<>0) Then

mouseinfo:='1.系统检测到鼠标;'

Else  mouseinfo:='1.系统没有鼠标;';

//检测鼠标是否支持滑动

If (GetSystemMetrics(SM_MOUSEWHEELPRESENT)<> 0) Then

mouseinfo:=mouseinfo+'2.系统支持滑动鼠标。'

Else  mouseinfo:=mouseinfo+'2.系统不支持滑动鼠标。';

Label1.Caption:=mouseinfo;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

SwapMouseButton(True);    //交换左右键

end;

procedure TForm1.Button5Click(Sender: TObject);

begin

SwapMouseButton(False); //复原左右键

end;

end.

Delphi锁定鼠标 模拟左右键 静止一会自动隐藏鼠标的更多相关文章

  1. Echarts X轴内容过长自动隐藏,鼠标移动上去显示全部名称方法

    最近公司做项目,使用echarts做开发,碰到一些数据的名称很长导致图例展示的效果不是很好,自己写了一个方法,当X轴内容过长时自动隐藏,鼠标移动上去显示全部名称 样例: 图二是鼠标移动到名称显示的,怎 ...

  2. C# winform 实现 qq 在屏幕边缘 自动隐藏 鼠标移过去 移上去 又自动显示

    代码下载地址   http://download.csdn.net/detail/simadi/7677147

  3. 转---JS 获取鼠标左右键

    原文:http://blog.csdn.net/mine3333/article/details/7291557 function test() { alert(event.x+" &quo ...

  4. JS中鼠标左右键以及中键的事件

    在三维场景中有时候需要判断鼠标的事件,除了使用的click事件,只有鼠标左键有效,而右键无效.而对于onmousedown.onmouseup的时候鼠标的事件左键/右键有效.详细请看w3c上的资料. ...

  5. 【新特性速递】单元格导航(上下左右键,TAB键和ENTER键)

    上下左右按键 其实单元格导航(上下左右按键,需要启用表格的ShowSelectedCell属性)一直都存在,只不过之前的版本(v5.5.0)有一些小的BUG. BUG1 比如锁定列存在时,上下左右键只 ...

  6. windows桌面图标不显示,左右键无法使用的解决方法

    问题描述: 日常使用软件中,一返回桌面,桌面图标全部不显示,点击鼠标的左键,右键毫无反应 解决方法: 1. Ctrl+Shift+Esc呼出软仵管理器 2. 右键windows资管理器,点击属性 配图 ...

  7. 鼠标模拟点击a标签

    今天写程序遇到的,想要用鼠标模拟点击a标签 html代码如下: <a id="jump"></a> js代码如下: var page = ....; $(' ...

  8. selenium 键盘鼠标模拟

    一.键盘模拟常用的键 sendKeys(Keys.BACK_SPACE);  //删除键--Backspace sendKeys(Keys.SPACE);   //空格键 Space sendKeys ...

  9. unity中锁定鼠标移动&&隐藏鼠标&&强制是鼠标移动到某一位置

    [System.Runtime.InteropServices.DllImport("user32.dll")] //引入dll public static extern int ...

随机推荐

  1. 【BZOJ】1697: [Usaco2007 Feb]Cow Sorting牛排序(置换群)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1697 置换群T_T_T_T_T_T_T 很久以前在黑书和白书都看过,,,但是看不懂... 然后找了本 ...

  2. CefGlue 学习杂记

    1. hg clone代码回来后,还要下载对应的cef dll .  从http://xilium.bitbucket.org/cefglue/ 选择对应的. 然后把dll和resource目录里的内 ...

  3. PHPmailer发送邮件时的常见问题及解决办法

    来源:http://www.chinastor.com/a/jishu/mailserver/0G392262014.html 使用PHPmailer发送邮件时的常见问题总结: 一,没有定义发送邮箱$ ...

  4. 怎么隐藏MathType标尺

    因为MathType公式编辑能力非常的好用,所以非常的受大家的欢迎.MathType用现有的模板可以直接输入输出各种公式,而且MathType中有着各式各样的数学符号满足了大家日常公式的需求,为大家的 ...

  5. IOS内购支付服务器验证模式

    IOS 内购支付两种模式: 内置模式 服务器模式 内置模式的流程: app从app store 获取产品信息 用户选择需要购买的产品 app发送支付请求到app store app store 处理支 ...

  6. python练习题-3

    author:headsen chen date: 2018-06-01  15:51:05 习题 31:  作出决定(if + raw_input) [root@localhost py]# cat ...

  7. ArcGIS中的 .tpk数据

    转:http://blog.csdn.net/mytudousi/article/details/33347249 什么是tpk文件 tpk是ArcGIS10.1推出的一种新的数据文件类型,主要是用于 ...

  8. 参数估计(1):从最小二乘到最小b乘

    机器学习到底学习到了什么,或者说“训练”步骤到底在做些什么?在我看来答案无非是:所谓的“学习”就是把大量的数据归纳到少数的参数中,“训练”正是估计这些参数的过程.所以,除了“参数估计”, 我想不到还有 ...

  9. fiddler弱网测试

    模拟低速网路环境…启用方法如下: Rules → Performances → Simulate Modem Speeds (如下图)· 勾选之后,你会发现你的网路瞬间慢超多… (想当年国中时我们的网 ...

  10. Exchange Pause or stop transport service

    The Microsoft Exchange Transport service is a service available both on the Microsoft Exchange Serve ...