话不多说,看代码 <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _ Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, <[In](), Out()> ByRef rect As RECT) As Boolean End Function <DllImport("user32.dll")> _ Private Shared Function WindowFromPoint(ByVal Point As System.Drawing.Point) As IntPtr End Function Private Sub Button1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown Cursor.Current = Cursors.NoMove2D Timer1.Enabled = True End Sub Declare Function GetCursorPos Lib "user32.dll" _ (ByRef lpPoint As Point) As Boolean Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim L As New RECT GetWindowRect(WindowFromPoint(MousePosition), L) Dim J As New StringBuilder(255) GetWindowText(WindowFromPoint(MousePosition), J, 255) Button1.Text = J.ToString Dim b As Bitmap = New Bitmap(L.Size.Width, L.Size.Height) Dim g As Graphics = Graphics.FromImage(b) g.CopyFromScreen(New Point(L.left, L.top), New Point(0, 0), L.Size, CopyPixelOperation.SourceCopy) PictureBox1.Image = b PictureBox1.Size = L.Size Me.Text = MousePosition.ToString End Sub <StructLayout(LayoutKind.Sequential)> _ Public Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer Public Sub New(ByVal left As Integer, ByVal top As Integer, ByVal right As Integer, ByVal bottom As Integer) Me.left = left Me.top = top Me.right = right Me.bottom = bottom End Sub Public Sub New(ByVal r As Rectangle) Me.left = r.Left Me.top = r.Top Me.right = r.Right Me.bottom = r.Bottom End Sub Public Shared Function FromXYWH(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As RECT Return New RECT(x, y, (x + width), (y + height)) End Function Public ReadOnly Property Size As Size Get Return New Size((Me.right - Me.left), (Me.bottom - Me.top)) End Get End Property End Structure Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim L As New RECT GetWindowRect(WindowFromPoint(MousePosition), L) Dim J As New StringBuilder(255) GetWindowText(WindowFromPoint(MousePosition), J, 255) Button1.Text = J.ToString Dim b As Bitmap = New Bitmap(L.Size.Width, L.Size.Height) Dim g As Graphics = Graphics.FromImage(b) g.CopyFromScreen(New Point(L.left, L.top), New Point(0, 0), L.Size, CopyPixelOperation.SourceCopy) PictureBox1.Image = b PictureBox1.Size = L.Size Me.Text = MousePosition.ToString End Sub Private Sub Button1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp 'Dim J As System.Drawing.Point 'GetCursorPos(J) Dim L As New RECT GetWindowRect(WindowFromPoint(MousePosition), L) Dim J As New StringBuilder(255) GetWindowText(WindowFromPoint(MousePosition), J, 255) Button1.Text = J.ToString Dim b As Bitmap = New Bitmap(L.Size.Width, L.Size.Height) Dim g As Graphics = Graphics.FromImage(b) g.CopyFromScreen(New Point(L.left, L.top), New Point(0, 0), L.Size, CopyPixelOperation.SourceCopy) PictureBox1.Image = b PictureBox1.Size = L.Size Me.Text = MousePosition.ToString Timer1.Enabled = False End Sub