关于vb sendmessage的问题
我希望通过运行该程序,按下指定的热键以获取在其他程序中鼠标选中的字符串。m=SendMessage(hactive,WM_GETTEXT,strlong,ByValstr...
我希望通过运行该程序,按下指定的热键以获取在其他程序中鼠标选中的字符串。
m = SendMessage(hactive, WM_GETTEXT, strlong, ByVal str)
hactive是当前活动的窗口,字符串变量被存入str变量中.
经过测试句柄并没有出现取错的现象.
但是str始终是活动窗口的标题而非选中的文本。
请问是哪里出错了吗?还是这里不能用GETTEXT的命令 展开
m = SendMessage(hactive, WM_GETTEXT, strlong, ByVal str)
hactive是当前活动的窗口,字符串变量被存入str变量中.
经过测试句柄并没有出现取错的现象.
但是str始终是活动窗口的标题而非选中的文本。
请问是哪里出错了吗?还是这里不能用GETTEXT的命令 展开
2个回答
展开全部
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Dim pt as POINTAPI
Dim hnd as long
GetCursorPos pt '先得到鼠标位置
hnd = WindowFromPoint(pt.x,pt.y) '获得鼠标所在位置的窗口句柄
SendMessage hnd,WM_GETTEXT,strlong,Byval str '发送WM_GETTEXT消息
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Dim pt as POINTAPI
Dim hnd as long
GetCursorPos pt '先得到鼠标位置
hnd = WindowFromPoint(pt.x,pt.y) '获得鼠标所在位置的窗口句柄
SendMessage hnd,WM_GETTEXT,strlong,Byval str '发送WM_GETTEXT消息
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询