⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gettopwindowcaption.txt

📁 一部分关于VB编程的小技巧
💻 TXT
字号:
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Const GW_HWNDNEXT = 2
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As Any, ByVal lpszWindow As Any) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwprocessid As Long) As Long

Function GetCaption(Hwnd As Long) As String
Dim Wintext As String
Dim slength As Long
Dim retval As Long

'Gets the Length of the Caption
slength = SendMessage(Hwnd, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1
'Makes Space for the Caption
Wintext = Space(slength)
'Gets The Caption
retval = SendMessage(Hwnd, WM_GETTEXT, ByVal slength, ByVal Wintext)
'Puts It in GetCaption
GetCaption = Left(Wintext, retval)
End Function

Function GetTopWindowCaption() As String
GetTopWindowCaption = GetCaption(GetForegroundWindow)
End Function



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -