📄 findwindowlike.txt
字号:
Option Explicit
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) 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 GetForegroundWindow Lib "user32.dll" () As Long
Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
'********************************************
'*Give it part of the window text your looking for
'*it will give you the hWnd
'*usefull for windows that text is like "[project] - microsoft visual basic [design]"
'*usage:
'*Msgbox FindWindowLike("visual basic")
'*Returns 0 if not found
'*******************************************
Function FindWindowLike(strPartOfCaption As String) As Long
Dim hWnd As Long
Dim strCurrentWindowText As String
Dim r As Integer
hWnd = GetForegroundWindow
Do Until hWnd = 0
strCurrentWindowText = Space$(255)
r = GetWindowText(hWnd, strCurrentWindowText, 255)
strCurrentWindowText = Left$(strCurrentWindowText, r)
'hWnd = GetWindow(hWnd, GW_CHILD)
If InStr(1, LCase(strCurrentWindowText), LCase(strPartOfCaption)) <> 0 Then GoTo Found
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
Loop
Exit Function
Found:
FindWindowLike = hWnd
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -