Макрос для Visual Studio 2005
Все примеры которые нашел видимо написаны на более старых версиях бэйзика и вижуалка считает что там есть даже синтаксические ошибки ни то чтоб оно еще и работало.
Вот код который написал на базе примера :
Private Structure POINTAPI
Dim X As Long
Dim Y As Long
End Structure
Private Declare Function GetCursorPos Lib "user32.dll" (ByVal lpPoint As POINTAPI) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As POINTAPI) As Long
Public Function RichWordOver(ByVal X As Single, ByVal Y As Single) As String
Dim pt As POINTAPI
Dim pos As Integer
Dim start_pos As Integer
Dim end_pos As Integer
Dim ch As String
Dim txt As String
Dim txtlen As Integer
pt.X = X
pt.Y = Y
X = GetForegroundWindow
pos = SendMessage(GetForegroundWindow, EM_CHARFROMPOS, 0&, pt)
If pos <= 0 Then Exit Function
txt = GetForegroundWindow.Text
For start_pos = pos To 1 Step -1
ch = Mid$(GetForegroundWindow.Text, start_pos, 1)
If Not ((ch >= "0" And ch <= "9") Or (ch >= "a" And ch <= "z") Or (ch >= "A" And ch <= "Z") Or ch = "_") Then Exit For
Next start_pos
start_pos = start_pos + 1
txtlen = Len(txt)
For end_pos = pos To txtlen
ch = Mid$(txt, end_pos, 1)
If Not ((ch >= "0" And ch <= "9") Or (ch >= "a" And ch <= "z") Or (ch >= "A" And ch <= "Z") Or ch = "_") Then Exit For
Next end_pos
end_pos = end_pos - 1
If start_pos <= end_pos Then RichWordOver = Mid$(txt, start_pos, end_pos - start_pos + 1)
End Function
но он к сожелению возврщает всегда позицию курсора 0,0 а при посылке сообщения и вовсе выдает ошибку.