zoukankan      html  css  js  c++  java
  • get hwnd of each window with python

    coding:utf-8

    print each window

    import win32gui
    import ctypes

    EnumWindows = ctypes.windll.user32.EnumWindows
    EnumWindowsProc = ctypes.WINFUNCTYPE(
    ctypes.c_bool,
    ctypes.POINTER(ctypes.c_int),
    ctypes.POINTER(ctypes.c_int))
    GetWindowText = ctypes.windll.user32.GetWindowTextW
    GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
    IsWindowVisible = ctypes.windll.user32.IsWindowVisible

    name = '姚峰杰'.decode('utf-8')
    hwnd = win32gui.FindWindow(0, name)

    titles = []
    def foreach_window(hwnd, lParam):
    if IsWindowVisible(hwnd):
    length = GetWindowTextLength(hwnd)
    buff = ctypes.create_unicode_buffer(length + 1)
    GetWindowText(hwnd, buff, length + 1)
    titles.append(hwnd) # , buff.value
    return True
    EnumWindows(EnumWindowsProc(foreach_window), 0)

    for i in range(len(titles)):
    print titles[i]

    ctypes.windll.user32.MoveWindow(titles[5][0], 0, 0, 760, 500, True)

    ctypes.windll.user32.SwitchToThisWindow(hwnd, True)

  • 相关阅读:
    Mac Mysql 修改初始化密码
    网址收藏
    Xcode 模拟器复制解决方案
    ios优秀的第三方框架
    CocoaPods第三方库管理工具
    ios网络请求
    java面试宝典
    SQL分表
    FastDFS+Nginx+Module
    分布式文件系统FastDFS架构认知
  • 原文地址:https://www.cnblogs.com/otfsenter/p/6548029.html
Copyright © 2011-2022 走看看