Ejemplo n.º 1
0
 def Find(self):
     winClassMatch = self.winClassMatch
     winNameMatch = self.winNameMatch
     programMatch = self.programMatch
     includeInvisible = self.includeInvisible
     topWindowsHwnds = [
         hwnd for hwnd in GetTopLevelWindowList(includeInvisible)
             if (
                 winClassMatch(GetClassName(hwnd)) and
                 winNameMatch(GetWindowText(hwnd))
             )
     ]
     if self.program:
         topWindowsHwnds = [
             hwnd for hwnd in topWindowsHwnds
                 if programMatch(GetWindowProcessName(hwnd).upper())
         ]
     if not self.scanChilds:
         return topWindowsHwnds
     childClassMatch = self.childClassMatch
     childNameMatch = self.childNameMatch
     childHwnds = [
         childHwnd for parentHwnd in topWindowsHwnds
             for childHwnd in GetWindowChildsList(
                 parentHwnd, includeInvisible
             )
                 if (
                     childClassMatch(GetClassName(childHwnd)) and
                     childNameMatch(GetWindowText(childHwnd))
                 )
     ]
     return childHwnds
Ejemplo n.º 2
0
 def __init__(self, parent, hwnds):
     wx.ListCtrl.__init__(self,
                          parent,
                          style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
     listmix.ListCtrlAutoWidthMixin.__init__(self)
     imageList = wx.ImageList(16, 16)
     imageList.Add(GetInternalBitmap("cwindow"))
     self.AssignImageList(imageList, wx.IMAGE_LIST_SMALL)
     self.InsertColumn(0, "Program")
     self.InsertColumn(1, "Name")
     self.InsertColumn(2, "Class")
     self.InsertColumn(3, "Handle", wx.LIST_FORMAT_RIGHT)
     for hwnd in hwnds:
         imageIdx = 0
         icon = GetHwndIcon(hwnd)
         if icon:
             imageIdx = imageList.AddIcon(icon)
         idx = self.InsertImageStringItem(sys.maxint,
                                          GetWindowProcessName(hwnd),
                                          imageIdx)
         self.SetStringItem(idx, 1, GetWindowText(hwnd))
         self.SetStringItem(idx, 2, GetClassName(hwnd))
         self.SetStringItem(idx, 3, str(hwnd))
     for i in range(4):
         self.SetColumnWidth(i, -2)
         headerSize = self.GetColumnWidth(i)
         self.SetColumnWidth(i, -1)
         labelSize = self.GetColumnWidth(i)
         if headerSize > labelSize:
             self.SetColumnWidth(i, headerSize)