※ 引述《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)