Projects

Find all our projects in development below.
All source code is GNU General Public License (GPL)

Window Spy

Browsing EnumWindowsForm.frm (11.05 KB)

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form EnumWindowsForm 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Advanced Window Spy"
   ClientHeight    =   3975
   ClientLeft      =   150
   ClientTop       =   435
   ClientWidth     =   9495
   ClipControls    =   0   'False
   Icon            =   "EnumWindowsForm.frx":0000
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3975
   ScaleWidth      =   9495
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.CheckBox Check1 
      Caption         =   "&Show Only Windows with Captions"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Left            =   1440
      TabIndex        =   3
      Top             =   3645
      Value           =   1  'Checked
      Width           =   2775
   End
   Begin MSComctlLib.ListView ListView2 
      Height          =   3135
      Left            =   4800
      TabIndex        =   1
      ToolTipText     =   "Child Windows"
      Top             =   120
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   5530
      SortKey         =   1
      View            =   3
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   12582912
      BackColor       =   16777215
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Handle"
         Object.Width           =   1270
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Class Name"
         Object.Width           =   2302
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Caption/Text"
         Object.Width           =   7056
      EndProperty
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   3135
      Left            =   120
      TabIndex        =   0
      ToolTipText     =   "Parent Windows"
      Top             =   120
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   5530
      SortKey         =   2
      View            =   3
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   0
      BackColor       =   16777215
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Handle"
         Object.Width           =   1270
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Class Name"
         Object.Width           =   2302
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Caption/Text"
         Object.Width           =   7056
      EndProperty
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Close"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   8160
      TabIndex        =   4
      Top             =   3480
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "&Refresh"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   3480
      Width           =   1215
   End
   Begin VB.Menu ListViewPopupMenu 
      Caption         =   "ListViewPopupMenu"
      Visible         =   0   'False
      Begin VB.Menu ShowMenu 
         Caption         =   "&Show"
      End
      Begin VB.Menu HideMenu 
         Caption         =   "&Hide"
      End
      Begin VB.Menu Blank1 
         Caption         =   "-"
      End
      Begin VB.Menu MinimizeMenu 
         Caption         =   "&Minimize"
      End
      Begin VB.Menu MaximizeMenu 
         Caption         =   "Ma&ximize"
      End
      Begin VB.Menu RestoreMenu 
         Caption         =   "&Restore"
      End
      Begin VB.Menu Blank2 
         Caption         =   "-"
      End
      Begin VB.Menu EnableMenu 
         Caption         =   "&Enable"
      End
      Begin VB.Menu DisableMenu 
         Caption         =   "&Disable"
      End
      Begin VB.Menu Blank3 
         Caption         =   "-"
      End
      Begin VB.Menu UnloadMenu 
         Caption         =   "&Unload/Close"
      End
      Begin VB.Menu ClickButtonMenu 
         Caption         =   "&Click Button"
      End
      Begin VB.Menu Blank4 
         Caption         =   "-"
      End
      Begin VB.Menu MenuSpyMenu 
         Caption         =   "&Menu Spy..."
      End
      Begin VB.Menu PropertiesMenu 
         Caption         =   "&Properties"
      End
   End
End
Attribute VB_Name = "EnumWindowsForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Selected_hWnd As Long
Dim Selected_ListViewObj As ListView
Dim ShowMenuSpy As Boolean
Sub AddListViewItem(ListViewObj As ListView, ByVal Text As String, ByVal SubItem1 As String, ByVal SubItem2 As String)
Dim LI As Object
Set LI = ListViewObj.ListItems.Add()
LI.Text = Text
LI.SubItems(1) = SubItem1
LI.SubItems(2) = SubItem2
Set LI = Nothing
End Sub


Private Sub Check1_Click()
Command1_Click
End Sub

Private Sub ClickButtonMenu_Click()
ClickButton Selected_hWnd
End Sub

Private Sub Command1_Click()
ListView1.ListItems.Clear
ListView2.ListItems.Clear
StartWinEnum ListView1
End Sub
Private Sub Command2_Click()
Unload Me
End Sub


Private Sub DisableMenu_Click()
WindowEnabled Selected_hWnd, False
End Sub

Private Sub EnableMenu_Click()
WindowEnabled Selected_hWnd, True
End Sub


Private Sub Form_Load()
Command1_Click
ShowMenuSpy = False
End Sub

Private Sub HideMenu_Click()
SetWindowState Selected_hWnd, SW_HIDE
End Sub

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
ListView1.SortOrder = Abs(Not (ListView1.SortOrder * -1))
ListView1.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
ListView2.ListItems.Clear
StartChildWinEnum Val(Item), ListView2
End Sub

Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton And ListView1.ListItems.Count > 0 Then
Selected_hWnd = Val(ListView1.SelectedItem)
Set Selected_ListViewObj = ListView1
If MenuExists(Selected_hWnd) > 0 Then
MenuSpyMenu.Enabled = True
Else
MenuSpyMenu.Enabled = False
End If
Blank4.Visible = True
MenuSpyMenu.Visible = True
PopupMenu ListViewPopupMenu, vbPopupMenuRightButton
If ShowMenuSpy Then
ShowMenuSpy = False
If MainForm.GetAOTValue Then WindowOnTop EnumMenusForm.hWnd, True
EnumMenusForm.Set_hWnd Selected_hWnd
EnumMenusForm.Tree.Nodes.Clear
MenuSpy_BuildTree MenuExists(Selected_hWnd), EnumMenusForm.Tree
If EnumMenusForm.Tree.Nodes.Count = 0 Then
Unload EnumMenusForm
MsgBox "No menu items found on window " & Chr(34) & ListView1.SelectedItem.SubItems(2) & Chr(34), vbExclamation, "Menu Spy"
Else
EnumMenusForm.Show 1
End If
End If
End If
End Sub


Private Sub ListView2_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
ListView2.SortOrder = Abs(Not (ListView2.SortOrder * -1))
ListView2.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub ListView2_GotFocus()
ListView1.HideSelection = False
End Sub

Private Sub ListView2_LostFocus()
ListView1.HideSelection = True
End Sub


Private Sub ListView2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton And ListView2.ListItems.Count > 0 Then
Selected_hWnd = Val(ListView2.SelectedItem)
Set Selected_ListViewObj = ListView2
Blank4.Visible = False
MenuSpyMenu.Visible = False
PopupMenu ListViewPopupMenu, vbPopupMenuRightButton
End If
End Sub


Private Sub MaximizeMenu_Click()
SetWindowState Selected_hWnd, SW_MAXIMIZE
End Sub

Private Sub MenuSpyMenu_Click()
ShowMenuSpy = True
End Sub

Private Sub MinimizeMenu_Click()
SetWindowState Selected_hWnd, SW_MINIMIZE
End Sub


Private Sub PropertiesMenu_Click()
If MainForm.GetAOTValue Then WindowOnTop WindowPropForm.hWnd, True
WindowPropForm.SetHandle Selected_hWnd
WindowPropForm.Show 1
End Sub

Private Sub RestoreMenu_Click()
SetWindowState Selected_hWnd, SW_NORMAL
End Sub


Private Sub ShowMenu_Click()
SetWindowState Selected_hWnd, SW_SHOW
End Sub


Private Sub UnloadMenu_Click()
If CloseWindow(Selected_hWnd) Then
MsgBox "The window was unloaded successfully.", vbExclamation
Else
MsgBox "An error occurred while trying to unload the window.", vbExclamation
End If
If Selected_ListViewObj.Name = "ListView1" Then
Command1_Click
Else
ListView1_ItemClick ListView1.SelectedItem
End If
End Sub


Download EnumWindowsForm.frm

Back to file list


Back to project page