En un nuevo proyecto pongan un timer que se llame Timer1
y cuatro etiquetas
lblCoor
lblCaption
lblClass
lblhWnd
y metanle este codigo que no se de donde lo saque pero no andaba
(ahora si anda)
Código
Option Explicit 'Constantes para pasarle a la función Api SetWindowPos Const SWP_NOMOVE = 2 Const SWP_NOSIZE = 1 Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 ' ' Función Api SetWindowPos 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) As Long Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function WindowFromPoint Lib "user32.dll" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Type POINTAPI X As Long Y As Long End Type Dim Coor As POINTAPI Dim Buff As String * 255 Dim Hwn As Long Dim Class As String * 255 Private Sub Form_Load() Timer1.Interval = 1 Timer1.Enabled = True SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, _ SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub Timer1_Timer() 'Obtenemos las coordenadas del cursor GetCursorPos Coor 'Obtenemos el handler de la ventana sobre la cual esta el cursor Hwn = WindowFromPoint(Coor.X, Coor.Y) 'Obtenemos el caption de la ventana Call GetWindowText(Hwn, Buff, 255) 'Obtenemos la clase de la ventana Call GetClassName(Hwn, Class, 255) lblcoor.Caption = "Coordenadas: X: " & Coor.X & " Y: " & Coor.Y lblcaption.Caption = "Texto: " & Trim$(Buff) lblclass.Caption = "Clase: " & Trim$(Class) lblhwnd.Caption = "hWnd: " & Hwn End Sub
Disfruten