📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
'----------------------------------------------------------------------------------------------------------
'Author: Jonathan Morrison
'Date: 6/13/1998
'----------------------------------------------------------------------------------------------------------
'This is the main code module. It contains all of the API declares and CONST's
'
'This was done quick and dirty so if I didn't comment something or if there is a bug just let me know @:
' jonathan.morrison@aig.com
' OR
' jonathanm@mindspring.com
'----------------------------------------------------------------------------------------------------------
'C language TypeDef to hold the information about a Windows class.
Type wndClass
style As Long
lpfnwndproc As Long
cbClsextra As Long
cbWndExtra2 As Long
hInstance As Long
hIcon As Long
hCursor As Long
hbrBackground As Long
lpszMenuName As String
lpszClassName As String
End Type
'C language TypeDef to hold the size information for a given window.
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'API Declares
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, _
lpdwProcessId As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) _
As Long
Declare Function GetDesktopWindow Lib "user32" () As Long
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 SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal _
hWndInsertAfter As Long, ByVal X As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Declare Function GetActiveWindow Lib "user32" () As Long
Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
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 GetClassInfo Lib "user32" Alias "GetClassInfoA" (ByVal hInstance As Long, _
ByVal lpClassName As String, _
lpWndClass As wndClass) As Long
'----------------------------------------------------------------------------------------------------------
Public Const WM_ACTIVATE = &H6
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_TOPMOST = -1
Public Const GW_CHILD = 5
Public Const GW_HWNDNEXT = 2
'----------------------------------------------------------------------------------------------------------
Public Function GetOpenWindowNames() As Long
'----------------------------------------------------------------------------------------------------------
'Name: Function GetOpenWindowNames()
'
'Purpose: To retrieve all open windows in the system.
'
'Parameters: N/A
'
'Return: NONE
'----------------------------------------------------------------------------------------------------------
'Declare local variables
Dim lngDeskTopHandle As Long 'Used to hold the value of the Desktop handle.
Dim lngHand As Long 'Used to hold each windows handle as it loops.
Dim strName As String * 255 'Fixed length string passed to GetWindowText API call.
Dim lngWindowCount As Long 'Counter used to return the numberof open windows in the system.
'Get the handle for the desktop.
lngDeskTopHandle = GetDesktopWindow()
'Get the first child of the desktop window.
'(Note: The desktop is the parent of all windows in the system.
lngHand = GetWindow(lngDeskTopHandle, GW_CHILD)
'set the window counter to 1.
lngWindowCount = 1
'Loop while there are still open windows.
Do While lngHand <> 0
'Get the title of the next window in the window list.
GetWindowText lngHand, strName, Len(strName)
'Get the sibling of the current window.
lngHand = GetWindow(lngHand, GW_HWNDNEXT)
'Make sure the window has a title; and if it does add it to the list.
If Left$(strName, 1) <> vbNullChar Then
frmClassFinder.lstOpenWindows.AddItem Left$(strName, InStr(1, strName, vbNullChar))
lngWindowCount = lngWindowCount + 1
End If
Loop
'Return the number of windows opened.
GetOpenWindowNames = lngWindowCount
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -