📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form frmClassFinder
Caption = "Window Class Finder"
ClientHeight = 4995
ClientLeft = 4470
ClientTop = 2715
ClientWidth = 5910
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4995
ScaleWidth = 5910
Begin VB.CommandButton cmdRefreshClass
Caption = "Refresh Class"
Height = 435
Left = 4920
TabIndex = 16
Top = 1320
Width = 855
End
Begin VB.CommandButton cmdActivate
Caption = "&Activate"
Height = 300
Left = 4875
TabIndex = 9
Top = 645
Width = 840
End
Begin VB.Timer tmrWinClass
Interval = 100
Left = 4380
Top = 3360
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 300
Left = 4875
TabIndex = 4
Top = 240
Width = 840
End
Begin VB.ListBox lstOpenWindows
Height = 1620
Left = 105
Sorted = -1 'True
TabIndex = 3
Top = 660
Width = 4620
End
Begin VB.CommandButton cmdGetClass
Caption = "Get &Class"
Height = 315
Left = 4875
TabIndex = 1
Top = 1950
Visible = 0 'False
Width = 855
End
Begin VB.TextBox txtTitle
Height = 285
Left = 105
TabIndex = 0
Text = "Enter Window Title Here!"
Top = 240
Width = 4620
End
Begin VB.Label lblRight
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 225
Left = 75
TabIndex = 15
Top = 3885
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblBottom
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 225
Left = 75
TabIndex = 14
Top = 3405
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblLeft
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 225
Left = 75
TabIndex = 13
Top = 3645
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblTop
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 225
Left = 75
TabIndex = 12
Top = 3165
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblProcessID
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 225
Left = 75
TabIndex = 11
Top = 2925
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblCount
BackColor = &H00C0C0C0&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 240
Left = 120
TabIndex = 10
Top = 2595
Width = 5625
WordWrap = -1 'True
End
Begin VB.Label lblClass
Caption = "Current Window Class:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 240
Left = 2055
TabIndex = 8
Top = 4680
Width = 3735
WordWrap = -1 'True
End
Begin VB.Label Label3
Caption = "Current Window Class:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 240
Left = 75
TabIndex = 7
Top = 4665
Width = 1980
WordWrap = -1 'True
End
Begin VB.Line Line1
X1 = 120
X2 = 5760
Y1 = 4170
Y2 = 4170
End
Begin VB.Label Label2
Caption = "Current Window Title:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 225
Left = 90
TabIndex = 6
Top = 4290
Width = 1860
WordWrap = -1 'True
End
Begin VB.Label lblCurrent
Caption = "Current Window:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 360
Left = 2055
TabIndex = 5
Top = 4290
Width = 3735
WordWrap = -1 'True
End
Begin VB.Label lblClassName
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 120
TabIndex = 2
Top = 2340
Width = 5625
WordWrap = -1 'True
End
End
Attribute VB_Name = "frmClassFinder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdGetClass_Click()
'----------------------------------------------------------------------------------------------------------
'This sub locates information about a window when you select
'it from the list box.
'----------------------------------------------------------------------------------------------------------
Dim lngHand As Long
Dim strName As String * 255
Dim wndClass As wndClass
Dim lngProcID As Long
Dim rctTemp As RECT
'Locate the selected window and get its handle.
lngHand = FindWindow(vbNullString, txtTitle.Text)
'Using the handle obtained from FindWindow, get all class information
'about the selected window.
GetClassName lngHand, strName, Len(strName)
'If the name in the text box doesn't match a system window tell the user.
'Otherwise, get the process id and the window size info.
If Left$(strName, 1) = vbNullChar Then
lblClassName.Caption = "Window Not Found!!!"
Else
lblClassName.Caption = "Class Name: " & strName
GetWindowThreadProcessId lngHand, lngProcID
GetWindowRect lngHand, rctTemp
End If
'Load the labels with the info retrieved.
lblProcessID = "ProcessID: " & lngProcID
lblTop = "Top: " & rctTemp.Top
lblBottom = "Bottom: " & rctTemp.Bottom
lblLeft = "Left: " & rctTemp.Left
lblRight = "Right: " & rctTemp.Right
End Sub
Private Sub cmdRefresh_Click()
'Clear the list box and reload it with the current windows.
lstOpenWindows.Clear
lblCount.Caption = GetOpenWindowNames & " open Windows."
End Sub
Private Sub cmdActivate_Click()
'----------------------------------------------------------------------------------------------------------
'This sub activates the selected window.
'----------------------------------------------------------------------------------------------------------
'Variable to hold the handle to the window.
Dim lngHand As Long
'Find the window by class or title.
If Trim$(lblClassName.Caption) = "" Then
lngHand = FindWindow(vbNullChar, Trim$(txtTitle.Text))
Else
lngHand = FindWindow(Right$(lblClassName.Caption, (Len(lblClassName) - 12)), lstOpenWindows.Text)
End If
'Activate the selected window.
'Some windows are hidden so it will make the application the input app.
BringWindowToTop lngHand
End Sub
Private Sub cmdRefreshClass_Click()
Call cmdGetClass_Click
End Sub
Private Sub Form_Load()
'Make our app the top most window in the system.
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
'Highlight the text in txtTitle.
txtTitle.SelLength = Len(txtTitle.Text)
lblCount.Caption = GetOpenWindowNames & " open Windows."
End Sub
Private Sub lstOpenWindows_Click()
'Call the hidden cmdGetClass button.
txtTitle.Text = lstOpenWindows.Text
Call cmdGetClass_Click
End Sub
Private Sub tmrWinClass_Timer()
'Check every 100 ms for the current application int the
'system and load it's info to our form.
Dim lngHand As Long
Dim strName As String * 255
lngHand = GetForegroundWindow
GetWindowText lngHand, strName, Len(strName)
lblCurrent.Caption = strName
GetClassName lngHand, strName, Len(strName)
lblClass.Caption = strName
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -