VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 555 IMEMode = 3 'DISABLE Left = 330 PasswordChar = "*" TabIndex = 3 Text = "Text1" Top = 555 Width = 1215 End Begin VB.Timer Tim Enabled = 0 'False Interval = 100 Left = 2025 Top = 735 End Begin VB.CommandButton CmdStop Caption = "Stop" Height = 495 Left = 2655 TabIndex = 2 Top = 2130 Width = 1215 End Begin VB.CommandButton CmdStart Caption = "Start" Height = 495 Left = 885 TabIndex = 1 Top = 2160 Width = 1215 End Begin VB.TextBox Txt Height = 495 Left = 1605 TabIndex = 0 Top = 1350 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Type POINTAPI X As Long Y As Long End Type Dim Pos As POINTAPI Dim hResult As Long Dim hNow As Long Dim hLength As Long Dim bArr() As Byte, bArr2() As Byte Private Const WM_GETTEXT = &HD Private Const WM_GETTEXTLENGTH = &HE Private Declare Sub RtlMoveMemory Lib "KERNEL32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long) Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongFunction GetText(ByVal hWndNow As Long) As String hLength = SendMessage(hWndNow, WM_GETTEXTLENGTH, 0, 0) If hLength > 0 Then ReDim bArr(hLength + 1) As Byte, bArr2(hLength - 1) As Byte Call RtlMoveMemory(bArr(0), hLength, 2) Call SendMessage(hWndNow, WM_GETTEXT, hLength + 1, bArr(0)) Call RtlMoveMemory(bArr2(0), bArr(0), hLength) GetText = StrComp(bArr2, vbUnicode) Else GetText = "" End If End FunctionPrivate Sub CmdStart_Click() Tim.Enabled = True End SubPrivate Sub CmdStop_Click() Tim.Enabled = False End SubPrivate Sub Tim_Timer() hResult = GetCursorPos(Pos) hNow = WindowFromPoint(Pos.X, Pos.Y) If hNow <> Txt.hwnd Then Txt.Text = GetText(hNow) End If DoEvents End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text1
Height = 555
IMEMode = 3 'DISABLE
Left = 330
PasswordChar = "*"
TabIndex = 3
Text = "Text1"
Top = 555
Width = 1215
End
Begin VB.Timer Tim
Enabled = 0 'False
Interval = 100
Left = 2025
Top = 735
End
Begin VB.CommandButton CmdStop
Caption = "Stop"
Height = 495
Left = 2655
TabIndex = 2
Top = 2130
Width = 1215
End
Begin VB.CommandButton CmdStart
Caption = "Start"
Height = 495
Left = 885
TabIndex = 1
Top = 2160
Width = 1215
End
Begin VB.TextBox Txt
Height = 495
Left = 1605
TabIndex = 0
Top = 1350
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim Pos As POINTAPI
Dim hResult As Long
Dim hNow As Long
Dim hLength As Long
Dim bArr() As Byte, bArr2() As Byte
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Declare Sub RtlMoveMemory Lib "KERNEL32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongFunction GetText(ByVal hWndNow As Long) As String
hLength = SendMessage(hWndNow, WM_GETTEXTLENGTH, 0, 0)
If hLength > 0 Then
ReDim bArr(hLength + 1) As Byte, bArr2(hLength - 1) As Byte
Call RtlMoveMemory(bArr(0), hLength, 2)
Call SendMessage(hWndNow, WM_GETTEXT, hLength + 1, bArr(0))
Call RtlMoveMemory(bArr2(0), bArr(0), hLength)
GetText = StrComp(bArr2, vbUnicode)
Else
GetText = ""
End If
End FunctionPrivate Sub CmdStart_Click()
Tim.Enabled = True
End SubPrivate Sub CmdStop_Click()
Tim.Enabled = False
End SubPrivate Sub Tim_Timer()
hResult = GetCursorPos(Pos)
hNow = WindowFromPoint(Pos.X, Pos.Y)
If hNow <> Txt.hwnd Then
Txt.Text = GetText(hNow)
End If
DoEvents
End Sub