|
Submitted By:
jacobjordan
|
|
|
Rating:
|
| Views: 7,182 |
Language: VB.NET |
| Last Modified: July 7, 2008 |
| Instructions: Use the GetWindowText() function. I know, there is a lot of other stuff in there, but just ignore the rest. |
Snippet
' Imports
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Function GetForegroundWindow() As IntPtr
End Function
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Function GetWindowText(ByVal hWnd As IntPtr, ByVal lpWindowText As Text.StringBuilder, _
ByVal nMaxCount As Integer) As Integer
End Function
' /Imports
''' <summary>
''' Get's the handle and text of the foreground window
''' </summary>
Public Function GetWindowText() As Window
Dim title As New Text.StringBuilder(255)
Dim titleLength As Integer = GetWindowText(GetForegroundWindow(), title, title.Capacity + 1)
title.Length = titleLength
Dim w As New Window
w.Text = title.ToString()
w.Handle = GetForegroundWindow()
Return w
End Function
''' <summary>
''' Represents an open, visible window
''' </summary>
Public Structure Window
Public Handle As IntPtr
Public Text As String
End Structure
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|
What's Here?
- Members: 358,488
- Replies: 966,643
- Topics: 163,458
- Snippets: 4,999
- Tutorials: 1,329
- Total Online: 2,193
- Members: 125
- Guests: 2,068
|