Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions dragonfly/actions/action_startapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

BringApp(r"C:\Windows\system32\\notepad.exe").execute()

Note that the path to *notepad.exe* given above might not be correct for
.Note that the path to *notepad.exe* given above might not be correct for
your computer, since it depends on the operating system and its
configuration.

Expand Down Expand Up @@ -122,8 +122,10 @@ class BringApp(StartApp):
foreground. On the other hand, if no window is found the
application is started.

Note that the constructor arguments are identical to those used by
the :class:`StartApp` action class.
In addition to the constructor arguments used by the
:class:`StartApp` action class, it also accepts arguments
specifying an alternate executable and title text to use
when selecting a window to bring to the foreground.

"""

Expand All @@ -136,14 +138,27 @@ def __init__(self, *args, **kwargs):
- *cwd* (*str*, default *None*) --
if not *None*, then start the application in this
directory
- *target* (*str*, defaults to :class:StartApp` target) --
if specified, use this as the executable target of
:class:`FocusWindow`
- *title* (*str*, default *None*) --
if not *None*, use this as the title target of
:class:`FocusWindow`

"""
self._target = args[0].lower()
self._title = None

if "target" in kwargs:
self._target = kwargs.pop("target")
if "title" in kwargs:
self._title = kwargs.pop("title")

StartApp.__init__(self, *args, **kwargs)

def _execute(self, data=None):
self._log.debug("Bringing app: %r" % (self._args,))
target = self._args[0].lower()
focus_action = FocusWindow(executable=target)
focus_action = FocusWindow(executable=self._target,title=self._title)
# Attempt to focus on an existing window.
if not focus_action.execute():
# Failed to focus on an existing window, so start
Expand Down