pyrobot.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:Rapider 作者: yazdipour 项目源码 文件源码
def _enumerate_windows(self, visible=True):
    '''
    Loops through the titles of all the "windows."
    Spits out too much junk to to be of immediate use.
    Keeping it here to remind me how the ctypes
    callbacks work.
    '''

    # raise NotImplementedError('Not ready yet. Git outta here!')

    titles = []
    handlers = []

    def worker(hwnd, lParam):
      length = user32.GetWindowTextLengthW(hwnd) + 1
      b = ctypes.create_unicode_buffer(length)
      user32.GetWindowTextW(hwnd, b, length)
      if visible and user32.IsWindowVisible(hwnd):
        title = b.value
        if title:
          titles.append(title)
          handlers.append(hwnd)
      return True

    WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL,
                     HWND,
                     LPARAM)

    if not user32.EnumWindows(WNDENUMPROC(worker), True):
      raise ctypes.WinError()
    else:
      return handlers, titles
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号