当前位置:首页 > 程序设计 > VB程序设计 > 游戏辅助 > 详细内容
SPY++ 结合VB简单应用02010107-02源码
作者:潇潇  发布时间:2009/12/6  阅读次数:13212  字体大小: 【】 【】【
教学课题:SPY++ 结合VB简单应用之取目标窗口矩形坐标及设置鼠标指针
教学要点:VB编程坏境,以计算器为例模拟鼠标输入QQ号:854487915
教学步骤:1、认识API函数:SetCursorPosGetWindowRectRECT
SetCursorPos(设置鼠标指针),成功为非零,失败为零,返回类型:Long。参数一:目标坐标X,类型:Long;参数二:目标坐标Y,类型:Long。
Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long

GetWindowRect(取目标窗口矩形坐标),成功为非零,失败为零,返回类型:Long。参数一:目标窗口句柄,类型:Long,参数二:矩形坐标结构,类型RECT矩形坐标结构
Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long

Type RECT
Left As Long '屏幕到目标窗口的左边距
Top As Long '屏幕到目标窗口的顶边距
Right As Long '屏幕到目标窗口的右边距
Bottom As Long '屏幕到目标窗口的底边距
End Type

教学代码:
'API声明
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
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)

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type


Private Sub Command1_Click()
Dim ck_hwnd As Long     '定义计算器窗口句柄变量
ck_hwnd = FindWindow("SciCalc", "计算器") 'SciCalc 取计算器窗口句柄
Text1.Text = Str(ck_hwnd)
Dim ck_R As RECT
If ck_hwnd <> 0 Then
       GetWindowRect ck_hwnd, ck_R   ' 取计算器窗口矩形范围坐标,或左上角坐标及右下角坐标
       Label2.Caption = Str(ck_R.Left) & Str(ck_R.Top) & Str(ck_R.Right) & Str(ck_R.Bottom)
       SetCursorPos 350 + ck_R.Left, 150 + ck_R.Top '设置鼠标指针
       'mouse_event()
      
End If
End Sub

来源:潇潇的编程网站
我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[1]
    暂无已审核评论!
Web Lite SWeTE: Simple Website Translation Engine
 


设为首页 | 加入收藏 | 意见建议 | 友情链接 | 版权声明 | 管理登陆 | 编程论坛 | 给我留言

声明:本网站部分稿件来源的所有文字、图片和音视频稿件,来自互联网,若侵犯您的权利,请来信告知,我们将在第一时间内删除!


Copyright 2009-2022 redrose ( wgbcw.com ) All rights reserved ICP备案编号:滇ICP备09007156号 Dict.cn


点击这里给我发消息
点击这里给我发消息