كود العناوين تحت المؤشر

0

'ضع الكود في الفورم

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function SetWindowText Lib "user32" _
Alias "SetWindowTextA" (ByVal hwnd As Long, _
ByVal lpString As String) As Long
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String)
Private Declare Function GetWindow& Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long)
Private Declare Function Sendmessagebynum& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As String)
Private Declare Function GetCursorPos& Lib "user32" _
(lpPoint As POINTAPI)
Private Declare Function WindowFromPoint& Lib "user32" _
(ByVal x As Long, ByVal y As Long)
Private Declare Function ChildWindowFromPoint& Lib "user32" _
(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long)
Private Declare Function SetWindowPos& Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function UpdateWindow& Lib "user32" (ByVal hwnd As Long)
Const SWP_NOACTIVATE = &H10
Const SWP_NOREDRAW = &H8
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const HWND_BOTTOM = 1
Const SWP_HIDEWINDOW = &H80
Const WM_SETTEXT = &HC
Const WM_GETTEXT = &HD
Const WM_CHAR = &H102
Const WM_CLEAR = &H303
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
Const EM_SETPASSWORDCHAR = &HCC
Const EM_GETPASSWORDCHAR = &HD2
Const EN_CHANGE = &H300
Dim Abort, LastWindow&, LastCaption$
Private Type POINTAPI
x As Long
y As Long
End Type
Function GetCaption(hwnd) As String
Dim capt As String, TChars As String
capt$ = Space$(255)
TChars$ = GetWindowText(hwnd, capt$, 255)
GetCaption = Left$(capt$, TChars$)
End Function

Function GetText(hwnd) As String
Dim GetTrim As Long, TrimSpace As String, GetString As String
GetTrim = Sendmessagebynum(hwnd, 14, 0&, 0&)
TrimSpace$ = Space$(GetTrim)
GetString = SendMessageByString(hwnd, 13, GetTrim + 1, TrimSpace$)

GetText = TrimSpace$
End Function

Private Sub Form_Load()
Call SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0&, 0&, 0&, _
0&, SWP_NOMOVE Or SWP_NOSIZE)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Abort = 1
End Sub

Private Sub Timer1_Timer()
Dim mypoint As POINTAPI, A As Long, B As Long
Call GetCursorPos(mypoint)
A& = WindowFromPoint(mypoint.x, mypoint.y)
B& = ChildWindowFromPoint(A&, mypoint.x, mypoint.y)
If A& = Form1.hwnd Then Exit Sub
Label1.Caption = GetCaption(A&)
Label2.Caption = GetText(A&)
End Sub

جميع الحقوق محفوظه © Visual Basic 6 MAN