Advertisement
pjmakey2

controlar_minimizado

Sep 26th, 2012
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import win32gui
  2. import win32con
  3. import win32process
  4. import os
  5. import win32api
  6. import time
  7. import logging
  8.  
  9. toplist = []
  10. winlist = []
  11. def enum_callback(hwnd, results):
  12.     winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
  13.  
  14.  
  15. if __name__ == "__main__":
  16.     logging.basicConfig(format="%(asctime)s %(message)s", filename=r"c:\fulano.log", level=logging.DEBUG)
  17.     win32gui.EnumWindows(enum_callback, toplist)
  18.     for hwnd, title in winlist:
  19.         busqueda = ["contabilidad",
  20.                     "egresos",
  21.                     "salarios",
  22.                     "consulta del reloj de marcacion",
  23.                     "cartera de clientes"]
  24.         #logging.info(title.lower())
  25.         for b in busqueda:
  26.             if b  in title.lower():
  27.                 if win32gui.IsIconic(hwnd):
  28.                     logging.info("minimizado %s" % b)
  29.                     t, p = win32process.GetWindowThreadProcessId(hwnd)
  30.                     handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p)
  31.                     if handle:
  32.                         win32api.TerminateProcess(handle, 0)
  33.                         win32api.CloseHandle(handle)
  34.                     #close sessions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement