Si, es una de mis tantas malas costumbres
Código [Seleccionar]
Option Explicit
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 GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
'Dessa
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwprocessid As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) 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 Long
Private Type POINTAPI: x As Long: y As Long: End Type
Dim CtlHandle As Long
Private Sub Form_Load()
Me.BackColor = vbBlack
Me.ForeColor = vbWhite
Me.FontBold = True
Me.Top = 0: Me.Left = 0
Me.Width = 6450
Me.Height = 1000
Me.BorderStyle = 5
Timer1.Interval = 16
End Sub
Private Sub Timer1_Timer()
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
Dim Cor As POINTAPI
Call GetCursorPos(Cor)
Dim Handle As Long
Handle = WindowFromPoint(Cor.x, Cor.y)
If Handle <> CtlHandle Then
Dim idProc As Long
Call GetWindowThreadProcessId(Handle, idProc)
Dim Handle_Proceso As Long
Handle_Proceso = OpenProcess(&H400 + &H10, 0, idProc)
Dim Buffer As String
Buffer = Space$(255)
Dim ret As Long
ret = GetModuleFileNameExA(Handle_Proceso, 0, Buffer, 255)
Dim Ruta As String
Ruta = Left$(Buffer, ret)
Call CloseHandle(Handle_Proceso)
Me.Cls
Me.Print ""
Me.Print Ruta
Me.Caption = "PID = " & idProc
CtlHandle = Handle
End If
End Sub