📄 frmselect.frm
字号:
Height = 195
Left = 120
TabIndex = 42
Top = 7620
Width = 8115
End
Begin VB.Label lblCountProcess
BackStyle = 0 'Transparent
Caption = "1"
Height = 255
Left = 5220
TabIndex = 4
Top = 4320
Width = 2415
End
Begin VB.Label lblCountThreads
BackStyle = 0 'Transparent
Caption = "1"
Height = 255
Left = 2700
TabIndex = 3
Top = 4320
Width = 2415
End
Begin VB.Label lblCountWinds
BackStyle = 0 'Transparent
Caption = "1"
Height = 255
Left = 120
TabIndex = 2
Top = 4320
Width = 2415
End
End
Attribute VB_Name = "frmSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'
' I have been to great troubles to learn all of the techniques in this program.
' I have spent many, many hours and late nights coding the many functions which I
' have included. As much as I resent it, Planet Source Code requires that I put
' the source code in the zip file. So I have placed it in here for you to view.
' Please use it wisely. And give me credit for all of the hard work that I have
' done. My biggest fear is that somebody will do an almost straight rip of this
' code, and take the credit for themselves. Please do not let this happening. I'm
' placing a lot of trust there. So please, use this program, use this code, and
' give me credit for it. If anybody rips all my routines, then my secret spy's
' (and I have a lot of them, as soon as I hire them) will tell me, and I'll get
' into my private jet (as soon as I buy it) and track you down over the whole
' world and eventually KILL YOU. You get the idea? Thanks. Read on for something
' a little more interesting!
'
' Code is Copyright Jolyon Bloomfield, February 2000
'
Public ReturnhWnd As Long
Private Sub cmdAbout_Click()
Dim TextString As String
TextString = "WindowIt Version 1.0" & vbCrLf & _
"Programmed Jan-March 2000 by Jolyon Bloomfield (Jolyon_B@Hotmail.Com)" & vbCrLf & _
"Please read Readme.Txt for information on this program." & vbCrLf & _
vbCrLf & _
"Help: Click around to get the feel of how this application works. Is similar to Spy++ by Microsoft. Bug me to write a help files ;)"
MsgBox TextString, vbInformation, "About WindowIt"
End Sub
Private Sub cmdEnum_Click()
Dim Enumer As Enumerator
Set Enumer = New Enumerator
Enumer.EnumAll
Enumer.EnumInTreeView frmSelect.TreeviewWindows, frmSelect.imgListTreeView, "Desktop", "Process", "Thread", "Window", Full
lblCountWinds.Caption = "Number of Windows: " & Enumer.NumOfWinds
lblCountWinds.Visible = True
lblCountThreads.Caption = "Number of Threads: " & Enumer.NumOfThreads
lblCountThreads.Visible = True
lblCountProcess.Caption = "Number of Processes: " & Enumer.NumOfProcesses
lblCountProcess.Visible = True
UpdateInfo
Set Enumer = Nothing
End Sub
Private Sub cmdMouse_Click()
Dim Work As New Enumerator
If TreeviewWindows.SelectedItem Is Nothing Then
ReturnhWnd = 0
Else
Select Case TreeviewWindows.SelectedItem.Image
Case Is = "Desktop"
ReturnhWnd = Work.DesktopWind
Case Is = "Process"
ReturnhWnd = 0
Case Is = "Thread"
ReturnhWnd = 0
Case Is = "Window"
ReturnhWnd = Val(TreeviewWindows.SelectedItem.Tag)
End Select
End If
frmMouseSelect.DoStuph
If ReturnhWnd = 0 Then Exit Sub
If NodeExist(TreeviewWindows.Nodes, "_" & Work.Format8(ReturnhWnd)) Then
Else
cmdEnum.Value = True
End If
On Error Resume Next
TreeviewWindows.Nodes("_" & Work.Format8(ReturnhWnd)).Selected = True
If Err Then MsgBox "The window currently being search for is not a valid window handle. Please try again.", vbCritical, "Error": TreeviewWindows.Nodes.Clear: Exit Sub
TreeviewWindows_Click
End Sub
Private Sub cmdNext_Click()
If TypeName(TreeviewWindows.SelectedItem) = "Nothing" Then beep: Exit Sub
If Me.TreeviewWindows.SelectedItem.Image = "Window" Or Me.TreeviewWindows.SelectedItem.Image = "Desktop" Then
Else
Exit Sub
End If
Dim hWnd As Long
Dim MyEnum As Enumerator
hWnd = Val(Me.TreeviewWindows.SelectedItem.Tag)
Set MyEnum = New Enumerator
If MyEnum.IsValidWindow(hWnd) = False Then MsgBox "It appears that the window that you have selected has been closed since the enumeration was performed. Please re-enumerate the windows, and try again.", vbInformation, "Error": Exit Sub
Set MyEnum = Nothing
frmProperty.LookHwnd = hWnd
frmEdit.LookHwnd = hWnd
'Me.Hide
frmProperty.Show
frmProperty.WindowState = vbNormal
End Sub
Private Sub cmdTerminate_Click()
On Error GoTo Ender
If Me.TreeviewWindows.SelectedItem.Image = "Process" Or Me.TreeviewWindows.SelectedItem.Image = "Thread" Or Me.TreeviewWindows.SelectedItem.Image = "Window" Then
Dim Temp As Enumerator
Dim GetProcess As Long
Set Temp = New Enumerator
On Error GoTo 0
' Find the process selected
Do
If Me.TreeviewWindows.SelectedItem.Image = "Process" Then Exit Do
If Me.TreeviewWindows.SelectedItem.Image = "Desktop" Then Exit Sub
Set Me.TreeviewWindows.SelectedItem = Me.TreeviewWindows.SelectedItem.Parent
Loop
' This is the process
GetProcess = Val(Me.TreeviewWindows.SelectedItem.Tag)
If MsgBox("Are you SURE you want to forcefully terminate the process """ & Temp.ProcessName(GetProcess) & """? Terminating the wrong process, especially a system process may result in the whole machine crashing. Do you wish to proceed?", vbCritical Or vbYesNo, "Terminate Process") = vbYes Then
If Temp.KillProcess(GetProcess) = False Then
MsgBox "Process was not terminated successfully", vbCritical, "Error"
Else
MsgBox "Process was successfully terminated.", vbInformation, "Process Terminated"
End If
cmdEnum.Value = True
End If
Else
beep: Exit Sub
End If
Ender:
End Sub
Private Sub Form_Load()
lblCountWinds.Visible = False
lblCountThreads.Visible = False
lblCountProcess.Visible = False
Load frmEdit
Load frmProperty
Load frmMouseSelect
Me.Show
cmdEnum.Value = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim Enumit As New Enumerator
On Error Resume Next
Me.TreeviewWindows.Nodes("_" & Enumit.Format8(Enumit.DesktopWind)).Expanded = False
Me.TreeviewWindows.Nodes.Clear
Dim i As Form
For Each i In Forms
If i.Name = "frmMouseSelect" Then
Unload i
ElseIf i.Visible = False Then
Unload i
End If
Next i
End Sub
Private Sub TreeviewWindows_Click()
UpdateInfo
End Sub
Private Sub TreeviewWindows_DblClick()
If TreeviewWindows.SelectedItem Is Nothing Then Exit Sub
If TreeviewWindows.SelectedItem.Image = "Window" Then
If TreeviewWindows.SelectedItem.Child Is Nothing Then cmdNext.Value = True
End If
End Sub
Private Sub TreeviewWindows_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If Button And &H1 = &H1 Then TreeviewWindows.HitTest(X, Y).Selected = True
End Sub
Private Function NodeExist(ByRef NodeCol As Nodes, ByVal ParentKey As String)
Dim Dummy As String
On Error Resume Next
Dummy = NodeCol(ParentKey).Key
If Err Then NodeExist = False Else NodeExist = True
End Function
Private Sub UpdateInfo()
If TreeviewWindows.SelectedItem Is Nothing Then
With Me
.txtClass.Text = ""
.txtClientRect(0).Text = ""
.txtClientRect(1).Text = ""
.txtWindRect(0).Text = ""
.txtWindRect(1).Text = ""
.txthWnd.Text = ""
.txtParClass.Text = ""
.txtOther.Text = ""
.txtParhWnd.Text = ""
.txtProcessID.Text = ""
.txtProcessName.Text = ""
.txtProgClass.Text = ""
.txtProghWnd.Text = ""
.txtThreadID.Text = ""
.txtWndText.Text = ""
.chkEnabled.Value = 0
.chkVisible.Value = 0
End With
Exit Sub
End If
Dim Worker As New Enumerator
Dim hWnd As Long
Dim Use As RECT
Dim Ender As RECT
Dim Pointer As POINTAPI
Dim WorkerText As String
Dim XIncrement As Long
Dim YIncrement As Long
Dim Temper As Node
Select Case TreeviewWindows.SelectedItem.Image
' Desktop statistics and information
Case Is = "Desktop"
hWnd = Val(TreeviewWindows.SelectedItem.Tag)
With Me
.txthWnd.Text = Hex(hWnd)
.txtClass.Text = Worker.ClassName(hWnd)
.txtParhWnd.Text = Hex(Worker.ParentWind(hWnd))
.txtParClass.Text = Worker.ClassName(Worker.ParentWind(hWnd))
.txtProghWnd.Text = Hex(Worker.Progenitor(hWnd))
.txtProgClass.Text = Worker.ClassName(Worker.Progenitor(hWnd))
.txtProcessID.Text = Hex(Worker.WindProcess(hWnd))
.txtThreadID.Text = Hex(Worker.WindThread(hWnd))
.txtProcessName.Text = Worker.ProcessName(Worker.WindProcess(hWnd))
.txtWndText.Text = Worker.GetWindText(hWnd)
.chkEnabled.Value = Abs(Worker.IsEnabled(hWnd))
.chkVisible.Value = Abs(Worker.IsVisible(hWnd))
End With
' Get the Client Rectangles
Use = modConst.GetClientRects(hWnd)
Ender = modConst.GetWindowRects(hWnd)
With Use
' Sort out the correct Client co-ordiantes, according to the parent.
Pointer.X = Use.Left
Pointer.Y = Use.Top
Pointer = modConst.ClientToScreen(hWnd, Pointer)
XIncrement = Pointer.X - Ender.Left
YIncrement = Pointer.Y - Ender.Top
WorkerText = "(" & Trim(Str(.Left + XIncrement)) & ", " & Trim(Str(.Top + YIncrement)) & ")-(" & Trim(Str(.Right + XIncrement)) & ", " & Trim(Str(.Bottom + YIncrement)) & ")"
' Display them
Me.txtClientRect(0).Text = WorkerText
' The client Size
Me.txtClientRect(1).Text = Trim(Str(.Right - .Left)) & " x " & Trim(Str(.Bottom - .Top))
End With
' Put the Window Rectangle Co-ordinates in the text boxes
Use = modConst.GetWindowRects(hWnd)
With Use
Me.txtWindRect(0).Text = "(" & Trim(Str(.Left)) & ", " & Trim(Str(.Top)) & ")-(" & Trim(Str(.Right)) & ", " & Trim(Str(.Bottom)) & ")"
Me.txtWindRect(1).Text = Trim(Str(.Right - .Left)) & " x " & Trim(Str(.Bottom - .Top))
End With
Me.txtOther.Text = "This is the desktop window. "
If Worker.MenuHandle(hWnd) <> 0 Then Me.txtOther.Text = Me.txtOther.Text & "This window has a menu. "
' Process statistics and information
Case Is = "Process"
Dim ProcessID As Long
ProcessID = Val(Me.TreeviewWindows.SelectedItem.Tag)
With Me
.txthWnd.Text = ""
.txtClass.Text = ""
.txtParhWnd.Text = ""
.txtParClass.Text = ""
.txtProghWnd.Text = ""
.txtProgClass.Text = ""
.txtProcessID.Text = Hex(ProcessID)
.txtThreadID.Text = ""
.txtProcessName.Text = Worker.ProcessName(ProcessID)
.txtWndText.Text = ""
.chkEnabled.Value = False
.chkVisible.Value = False
.txtClientRect(0).Text = ""
.txtClientRect(1).Text = ""
.txtWindRect(0).Text = ""
.txtWindRect(1).Text = ""
.txtOther.Text = ""
End With
' Thread statistics and information
Case Is = "Thread"
Dim ThreadID As Long
ThreadID = Val(Me.TreeviewWindows.SelectedItem.Tag)
With Me
.txthWnd.Text = ""
.txtClass.Text = ""
.txtParhWnd.Text = ""
.txtParClass.Text = ""
.txtProghWnd.Text = ""
.txtProgClass.Text = ""
.txtProcessID.Text = Hex(Worker.ThreadProcess(ThreadID))
.txtThreadID.Text = Hex(ThreadID)
.txtProcessName.Text = Worker.ProcessName(Worker.ThreadProcess(ThreadID))
.txtWndText.Text = ""
.chkEnabled.Value = False
.chkVisible.Value = False
.txtClientRect(0).Text = ""
.txtClientRect(1).Text = ""
.txtWindRect(0).Text = ""
.txtWindRect(1).Text = ""
If Worker.ThreadHung(ThreadID) = False Then .txtOther.Text = "" Else .txtOther.Text = "This thread is HUNG!"
End With
' Window statistics and information
Case Is = "Window"
hWnd = Val(TreeviewWindows.SelectedItem.Tag)
With Me
.txthWnd.Text = Hex(hWnd)
.txtClass.Text = Worker.ClassName(hWnd)
.txtParhWnd.Text = Hex(Worker.ParentWind(hWnd))
.txtParClass.Text = Worker.ClassName(Worker.ParentWind(hWnd))
.txtProghWnd.Text = Hex(Worker.Progenitor(hWnd))
.txtProgClass.Text = Worker.ClassName(Worker.Progenitor(hWnd))
.txtProcessID.Text = Hex(Worker.WindProcess(hWnd))
.txtThreadID.Text = Hex(Worker.WindThread(hWnd))
.txtProcessName.Text = Worker.ProcessName(Worker.WindProcess(hWnd))
.txtWndText.Text = Worker.GetWindText(hWnd)
.chkEnabled.Value = Abs(Worker.IsEnabled(hWnd))
.chkVisible.Value = Abs(Worker.IsVisible(hWnd))
End With
' Get the Client Rectangles
Use = modConst.GetClientRects(hWnd)
Ender = modConst.GetWindowRects(hWnd)
With Use
' Sort out the correct Client co-ordiantes, according to the parent.
Pointer.X = Use.Left
Pointer.Y = Use.Top
Pointer = modConst.ClientToScreen(hWnd, Pointer)
XIncrement = Pointer.X - Ender.Left
YIncrement = Pointer.Y - Ender.Top
WorkerText = "(" & Trim(Str(.Left + XIncrement)) & ", " & Trim(Str(.Top + YIncrement)) & ")-(" & Trim(Str(.Right + XIncrement)) & ", " & Trim(Str(.Bottom + YIncrement)) & ")"
' Display them
Me.txtClientRect(0).Text = WorkerText
' The client Size
Me.txtClientRect(1).Text = Trim(Str(.Right - .Left)) & " x " & Trim(Str(.Bottom - .Top))
End With
' Put the Window Rectangle Co-ordinates in the text boxes
Use = modConst.GetWindowRects(hWnd)
With Use
Me.txtWindRect(0).Text = "(" & Trim(Str(.Left)) & ", " & Trim(Str(.Top)) & ")-(" & Trim(Str(.Right)) & ", " & Trim(Str(.Bottom)) & ")"
Me.txtWindRect(1).Text = Trim(Str(.Right - .Left)) & " x " & Trim(Str(.Bottom - .Top))
End With
If Worker.DesktopWind = Worker.Progenitor(hWnd) Then Me.txtOther.Text = "This window is a child of the desktop. " Else Me.txtOther.Text = ""
If Worker.MenuHandle(hWnd) <> 0 Then Me.txtOther.Text = Me.txtOther.Text & "This window has a menu. "
Set Temper = Me.TreeviewWindows.SelectedItem
Do
If Temper.Image = "Process" Then
If Worker.ProcessName(Worker.WindProcess(Val(TreeviewWindows.SelectedItem.Tag))) <> Worker.ProcessName(Val(Temper.Tag)) Then
Me.txtOther.Text = Me.txtOther.Text & "This window belongs to a different process. "
End If
Exit Do
ElseIf Temper.Image = "Desktop" Then
Exit Do
Else
Set Temper = Temper.Parent
End If
Loop
End Select
End Sub
Private Sub TreeviewWindows_NodeClick(ByVal Node As MSComctlLib.Node)
UpdateInfo
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -