## **描述**
点击指定坐标,可以指定相对于本窗口还是相对于屏幕,还可以指定点击次数以及每次点击的前后延时。
## **语法**
ClickPoint(*x1, y1[, PositionMod = relative[, clickTimes = 1[, delayMilliSecondsBefore = 0[, delayMilliSecondsAfter = 0]]]]*)
**该语法中有下列命名参数:**
| 参数 | 描述 |
| --- | --- |
| x1 | Long类型,表示要点击的Left坐标值。 |
| y2 | Long类型,表示要点击的Top坐标值。 |
| PositionMod | 可选的。enumPositionMode 类型,表示坐标使用绝对还是相对方式。如果忽略,**缺省值是relative,它表明坐标使用相对方式**,例如点击100,100这个点,默认会点击相对于窗口左顶点的位置100,100,如果要相对于屏幕可以设置本参数值为absolute。关于enumWindowVisible类型的介绍请参考下面“**enumPositionMode类型的设置值**”表的介绍。|
| clickTimes | 可选的。Integer 类型,表示点击次数。如果忽略,缺省值是 1,它表明点击1次。 |
| delayMilliSecondsBefore | 可选的。Long 类型,**表示点击前延时多久**,单位为毫秒(ms)。如果忽略,缺省值是 0,它表明点击前不延时。|
| delayMilliSecondsAfter | 可选的。Long 类型,**表示点击后延时多久**,单位为毫秒(ms)。如果忽略,缺省值是 0,它表明点击后不延时。|
**enumPositionMode类型的设置值:**
| 设置 | 描述 |
| --- | --- |
| absolute | 坐标使用绝对方式 |
| relative | 坐标使用相对方式 |
## **返回值**
| 无 |
| --- |
| - |
## **示例**
> 说明:请向窗口添加按钮Command1,然后复制下面代码后点击按钮运行。运行前先打开记事本
```
Private Sub Command1_Click()
Dim w As New clsWindow
w.GetWindowByClassName "Notepad" '获得记事本窗口
w.Wait 500
w.Focus '设置记事本窗口为活动窗口
w.Wait 500
w.ClickPoint 200, 200 '默认是相对模式(也就是记事本左顶点+100,记事本上顶点+100),未获取句柄之前是实际默认句柄是0,即桌面的窗口
w.Caption = "当前鼠标移动到相对记事本左上的200,200处了"
w.Wait 3000 '延时3秒以便观看效果
w.ClickPoint 200, 200, relative '和上面一样,默认就是relative,即相对模式
w.Wait 3000 '延时3秒以便观看效果
w.ClickPoint 200, 200, absolute '绝对模式,是相对于桌面左上顶点开始计算的
w.Caption = "当前鼠标移动到相对屏幕左上的200,200处了"
w.Wait 3000 '延时3秒以便观看效果
w.Caption = "以下延时根据菜单坐标点击相应菜单"
w.Focus '设置记事本窗口为活动窗口
w.ClickPoint 240, 30, , , 200, 300 '点击相对于记事本的(240,30)坐标处,实际是“帮助”菜单的位置,并且点击前延时200ms,点击后延时300ms
w.ClickPoint 240, 80, , , 200, 300 '点击坐标(240,80)坐标,实际正好是二级菜单“关于记事本”的位置
End Sub
```
- 关于clsWindow
- 一、获取窗口
- GetWindowByTitle 函数
- GetWindowByTitleEx 函数
- GetWindowByClassName 函数
- GetWindowByClassNameEx 函数
- GetWindowByPoint 函数
- GetWindowByAppName 函数
- GetWindowByAppNameEx 函数
- GetWindowByCursorPos 函数
- GetWindowByPID 函数
- GetWindowByHwnd 函数
- Load 函数(同GetWindowByHwnd)
- 二、操作窗口
- Focus 方法
- SetFocus 方法(同Focus)
- FadeIn 方法
- FadeOut 方法
- Transparent 函数
- SetTransparent 函数(同Transparent)
- MakeTransparent 函数(同Transparent)
- Shake 方法
- CloseWindow 函数
- ClassName 属性
- Caption 属性
- Text 属性(同Caption)
- Title 属性(同Caption)
- Value 属性(同Caption)
- ZOrder 方法
- Left 属性
- Top 属性
- Width 属性
- Height 属性
- Visible 属性
- Enabled 属性
- WindowState 属性
- AlphaBlend 属性
- TransparentColor 属性
- CheckWindow 函数
- Move 函数
- MoveToCenter 函数
- Show 函数
- Hide 函数
- Refresh 方法
- SetPosBottom 函数
- SetPosFront 函数
- SetPosNormal 函数
- SetTop 函数
- IsTopMost 函数
- IsForegroundWindow 属性
- Maximized 函数
- Minimized 函数
- Normal 函数
- Restore 函数(同Normal)
- 三、操作控件
- GetElementHwndByText 函数
- GetElementHwndByClassName 函数
- GetElementTextByText 函数
- GetElementTextByClassName 函数
- GetClassNameByHwnd 函数
- GetTextByHwnd 函数
- GetCaptionByHwnd 函数(同GetTextByHwnd)
- SetElementTextByText 函数
- SetElementTextByClassName 函数
- SelectComboBoxIndex 函数
- AppendElementTextByClassName 函数
- Click 函数
- ClickElementByText 函数
- ClickElementByClassName 函数
- SendKeys 方法
- Paste 方法
- FileToClipboard 函数
- ClipboardSetText 函数
- 四、鼠标坐标相关
- ClickCurrentPoint 方法
- ClickPoint 方法
- ClickPointBackground 方法
- SetCursor 方法
- MoveCursor 方法(同SetCursor)
- MoveCursorTo 方法(同SetCursor)
- SetPoint 方法(同SetCursor)
- GetCursorPoint 函数
- GetCursorPosCurrent 函数(同GetCursorPoint)
- MouseLeftDown 方法
- MouseLeftUp 方法
- MouseRightDown 方法
- MouseRightUp 方法
- DragTo 方法
- DragToEx 方法
- 五、应用程序相关
- AppPath 函数
- AppName 函数
- IsWin64 函数
- CommandLine 函数
- AppCommandLine 函数(同CommandLine)
- CloseApp 函数
- ProcessID 函数
- PID 函数(同ProcessID)
- 六、公有方法属性等
- hWnd 公有变量
- DebugMe 公有变量
- Wait 方法
- Version 方法
- 使用范例
- 01 控制微信发送消息
- 02 控制QQ发送消息
- 03 QQ登录器
- 04 花式调用计算器
- 05 用鼠标在画图工具上画圆
- 06 控制记事本输入并保存
- 07 随机移动鼠标防锁屏
- 08 根据ID进入腾讯课堂
- 09 限制程序重复打开
- 10 控制c2p软件将ceb转换为pdf格式
- 11 实战:微便签-窗口特效
- 12 实战:窗口图钉-窗口置顶
- 13 实战:微型按键精灵,录制和播放鼠标动作
- 一些Q&A
- 01 这个框架是免费的吗?
- 02 无句柄的控件元素如何操作?
- 03 目标窗体中有相同类名输入框如何区分填写?
- 04 为什么win10下最大化不生效?
- 05 如何确定绝对或相对坐标?
- 06 相同标题的窗口如何得到所有句柄?
- 联系我们