python - Window claims to be visible, while it's not -


i running following script in order find out whether process has visible windows:

import win32gui import win32process  pid = 6324  def windowisvisible(pid):     data = [pid, false]     win32gui.enumwindows(enumhandler, data)     return data[1]  def enumhandler(hwnd, data):     if win32process.getwindowthreadprocessid(hwnd)[1] == data[0] , win32gui.iswindowvisible(hwnd):         data[1] = true  if windowisvisible(pid):     print "has visible window" else:     print "does not have visible window" 

for reason, prints has visible window

however, taskbar , task manager looks like:

taskbar

enter image description here

how possible? outlook exe invisible (although it's visible in notification icon area)

enter image description here

that iswindowvisible returns true not mean able see window on screen. window minimized, instance. so, need check window both visible , not minimized @ leasy. use win32gui.isiconic() test window being minimized.

it entirely possible outlook has multiple top-level windows, covered @ previous question. approach detect whether or not of windows has visible property.

your code looks quite odd. passing pid function named windowisvisible feels wrong me. that's question ask of window rather process.

i think code more appropriate needs:

def toplevelwindows(pid):      def enumhandler(hwnd, data):         if win32process.getwindowthreadprocessid(hwnd)[1] == pid:             windows.append(hwnd)         return true      windows = []     win32gui.enumwindows(enumhandler, 0)     return windows  hwnd in toplevelwindows(pid):     if win32gui.iswindowvisible(hwnd) , not win32gui.isiconic(hwnd):         print '%.8x %s' % (hwnd, win32gui.getwindowtext(hwnd)) 

however, still enumerate top-level windows. , think looking outlook main window. suspect you'll need find way identify window.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -