PDA

Visualizza la versione completa : Py27 Win / Trovare finestra sottoposta


zacca94
06-05-2017, 13:20
Utilizzo questa mia funzione per trovare la finestra che sta "sotto" a quella sovrapposta:

def getHwndsForPid(pid):
def callback(hwnd, hwnds):
if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
_, foundPid = win32process.GetWindowThreadProcessId(hwnd)
if foundPid == pid:
hwnds.append(hwnd)
return True
## End def callback

hwnds = []
win32gui.EnumWindows(callback, hwnds)
return hwnds

def getTableByPos(left, top):
for proc in psutil.process_iter():
for hwnd in getHwndsForPid(proc.pid):
for tblName in tblNames:
tblTitle = (win32gui.GetWindowText(hwnd)).strip()
if re.search(tblName, tblTitle):
tblLeft, tblTop, tblRight, tblBottom = win32gui.GetWindowRect(hwnd)
if tblLeft < left and tblTop < top and tblRight > left and tblBottom > top:
return [hwnd, tblLeft, tblTop, tblRight, tblBottom]

Esiste giÓ qualche metodo delle librerie win32/ctypes?

zacca94
07-05-2017, 20:59
Risolto grazie a RicPol, di un famoso forum di python con: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633558(v=vs.85).aspx

Loading