Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setForeground で Firefoxがフォアグラウンド化できない #19

Open
crftwr opened this issue Nov 16, 2016 · 2 comments
Open

setForeground で Firefoxがフォアグラウンド化できない #19

crftwr opened this issue Nov 16, 2016 · 2 comments

Comments

@crftwr
Copy link
Owner

crftwr commented Nov 16, 2016

No description provided.

@crftwr
Copy link
Owner Author

crftwr commented Nov 27, 2016

Blogで下記で動くとのコメントあり。

def check_run(path, class_name=""):
wnd = find_window(class_name)
if wnd:
if wnd.isMinimized():
wnd.restore()
wnd.getLastActivePopup().setForeground()
else:
keymap.ShellExecuteCommand(None, path, "", "").executeFunc()

def find_window(class_name):
def get_window(wnd, arg):
nonlocal window
if wnd.isVisible() and not wnd.getOwner():
if wnd.getClassName() == class_name:
window = wnd
return False
return True

window = None
Window.enum(get_window, None)
return window

keymap_global["A-C"] = lambda: check_run(r"C:/Program Files/Mozilla Firefox/firefox.exe", "MozillaWindowClass")

@geotrader
Copy link

geotrader commented Nov 28, 2016

上のコードで動作しました。
インデント付きを置いておきます。

    def find_window(class_name):
        def get_window(wnd, arg):
            nonlocal window
            if wnd.isVisible() and not wnd.getOwner():
                if wnd.getClassName() == class_name:
                    window = wnd
                    return False
            return True
        window = None
        Window.enum(get_window, None)
        return window

    def check_run(path="", class_name=""):
        wnd = find_window(class_name)
        if wnd:
            if wnd.isMinimized():
                wnd.restore()
            wnd.getLastActivePopup().setForeground()
        else:
            executeFunc = keymap.ShellExecuteCommand(None, path, "", "")
            executeFunc()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants