YumYumYum YumYumYum - 1 year ago 129
Python Question

Python - why its not able to find the window title?

I have following code and its unable to activate the window title "Stack Overflow" and sending the f11 to wrong GUI.

Is this a Python bug? Why its not working?

import subprocess
from subprocess import Popen
import win32com.client as comctl
import time

def chromes():
Popen([cmd, url, '--window-position=0,0', '--user-data-dir=C:\\iplay'])


wsh =comctl.Dispatch("WScript.Shell")
aa = wsh.AppActivate("Stack Overflow")

Answer Source

Like this :

import win32gui
import win32api
import win32con

def enumHandler(hwnd, lParam):
    if win32gui.IsWindowVisible(hwnd):
        if 'Stack Overflow' in win32gui.GetWindowText(hwnd):
            win32api.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_F11, 0)

win32gui.EnumWindows(enumHandler, None)

But no idea about which tab effected ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download