Advertisement
Guest User

Show tasklist result

a guest
Nov 8th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import ctypes
  2.  
  3. EnumWindows = ctypes.windll.user32.EnumWindows
  4. EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
  5. GetWindowText = ctypes.windll.user32.GetWindowTextW
  6. GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
  7. IsWindowVisible = ctypes.windll.user32.IsWindowVisible
  8.  
  9. titles = []
  10. def foreach_window(hwnd, lParam):
  11.     if IsWindowVisible(hwnd):
  12.         length = GetWindowTextLength(hwnd)
  13.         buff = ctypes.create_unicode_buffer(length + 1)
  14.         GetWindowText(hwnd, buff, length + 1)
  15.         titles.append(buff.value)
  16.     return True
  17. EnumWindows(EnumWindowsProc(foreach_window), 0)
  18.  
  19. print(titles)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement