作者chinoyan ()
看板Visual_Basic
标题Re: [VB6 ] 滑鼠作标问题
时间Mon Jul 23 04:43:26 2012
※ 引述《jodo1984 (XDDD)》之铭言:
: 最近再研究滑鼠座标
: 最近网路上找到一些范例, 但是有有一些地方看不太懂
: 所以想请教板上高手...
: ret = GetCursorPos(pt)
: hwnd = WindowFromPoint(pt.x, pt.y)
: wndtext = Space(100)
: ret = GetWindowText(hwnd, wndtext, 100)
: OK = GetWord.GetString(ptCursor.x, ptCursor.y, bstr, nCursorPos)
: Label3.Caption = wndtext
: Text1.Text = pt.x
: Text2.Text = pt.y
: If GetAsyncKeyState(vbLeftButton) Then
: Text1.Text = pt.x
: Text2.Text = pt.y
: End If
: (1) GetCursorPos 按照字面上的意思因该是取得滑鼠目前座标
: 但是下一行为什麽不是 (ret.x, ret.y)
RET是传回取得成功与否,不是座标值
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
'POINTAPI 是自订结构
Public Type PointAPI
X As Long
Y As Long
End Type
Dim pt As PointAPI
: (2) GetWindowText 这一行完全看不懂...
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
传入 视窗的HWND ,准备一个够长的字串变数,丢给API,将传回 该视窗的标题文字
: (3) GetWord.GetString
没看过,你应该有少贴CODE
: (4) GetAsyncKeyState
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer
传回指定VKEY的状态
If GetAsyncKeyState(120) Then 'IF F9 按下
: 我查VB的书 完全没有提到这个部分...
: 谢谢
google: 王国荣 VB API
用API取字串 要特别用心看一下,要预先准备够长的字串长度,CHR(0)为结尾
中文和英文也有差别
--
████ █ ★ ████ █ █ █
█ █ █ █ █ █ 超 级 热 烈 欢 迎
█ ████ █ █ █ ████ █
█ █ █ █ ███★ █ █ 欢迎到嘉义版!
★███ █ █ █ █ █ █ █
讯驰电脑-路径 →
嘉义市林森西路496号 →
(05)2244-526 →
顺发斜对面
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.127.140.29
※ 编辑: chinoyan 来自: 59.127.140.29 (07/23 04:46)