Application¶
Application wraps a running process. Returned by Desktop.launch() and Desktop.connect().
Application
¶
Represents a running desktop application.
Do not instantiate directly — use :meth:Desktop.launch or
:meth:Desktop.connect.
Usage::
with desktop.launch("notepad.exe") as app:
win = app.window(title_re=".*Notepad")
win.get_by_role("Edit").type_text("hello")
Source code in src\dolphin_desktop\_application.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
window
¶
window(
alias: str | None = None,
*,
title: str | None = None,
title_re: str | None = None,
class_name: str | None = None,
auto_id: str | None = None,
found_index: int = 0,
timeout: float = 10.0,
) -> Window
Return a :class:Window matching the given criteria or Object Repository alias.
Waits up to timeout seconds for the window to become visible.
Args:
alias: Optional Object Repository alias. When given, the alias is
resolved to pywinauto criteria and the returned :class:Window
stores the alias name so that :meth:Window.element can look up
child elements from the same YAML entry.
Source code in src\dolphin_desktop\_application.py
top_window
¶
windows
¶
close
¶
Ask the application to close gracefully.
Source code in src\dolphin_desktop\_application.py
kill
¶
is_webview2
¶
Return True if this application hosts an Edge WebView2 control.
Detection checks whether the process has loaded WebView2Loader.dll,
which is present in every app built with the Microsoft WebView2 SDK.
Returns False on any OS error, never raises.
Source code in src\dolphin_desktop\_application.py
is_electron
¶
Return True if this application is built on the Electron/Chromium runtime.
Detection is done in two passes:
- Window class — Electron/Chromium main windows have class
Chrome_WidgetWin_1. This is fast and works without elevated privileges. - Module signatures — if window enumeration finds nothing (e.g.
called before the first window appears), the process module list is
checked for
vk_swiftshader,libglesv2orelectronDLLs that ship with every Electron build.
Returns False on any error so callers never need to guard against
exceptions.
Source code in src\dolphin_desktop\_application.py
is_cef
¶
Return True if this application uses the Chromium Embedded Framework (CEF).
Detection checks for libcef.dll in the process module list while
excluding Electron-specific DLLs (vk_swiftshader, libglesv2,
electron). Because Electron is itself built on CEF, both would
carry libcef.dll — the absence of Electron modules distinguishes a
standalone CEF app (Spotify, Steam, Battle.net, etc.) from Electron.
Call this method after the app's main window has loaded — CEF DLLs are loaded lazily during UI initialization.
.. note::
UIA accessibility coverage for CEF apps varies widely. Apps that
expose --force-renderer-accessibility (or enable it internally)
provide a richer UIA tree. Spotify and Steam use bitmap rendering
for most UI, leaving only the window frame and a few controls in
the UIA tree. See docs/cef.md for workarounds.
Returns False on any OS error, never raises.
Source code in src\dolphin_desktop\_application.py
is_legacy_ie
¶
Return True if this application hosts an IE/Trident (MSHTML) browser.
Detection checks whether the process has loaded mshtml.dll, the
MSHTML rendering engine used by the WPF WebBrowser control and
older IE-based components. This DLL is present in every WPF app that
instantiates a WebBrowser control, regardless of the URL loaded.
.. note::
IE/Trident is End-of-Life since June 2022. The WPF WebBrowser
control still works in .NET 4.8 and partially in .NET 8 (Windows),
but Microsoft no longer ships security patches for MSHTML.
For new projects use Edge WebView2 (see docs/webview2.md).
Returns False on any OS error, never raises.
Source code in src\dolphin_desktop\_application.py
Usage examples¶
Get a window¶
win = app.window(title_re=".*My App.*")
win = app.window(class_name="Notepad")
win = app.window(title="Exact Window Title")
Context manager (automatic teardown)¶
with desktop.launch("notepad.exe") as app:
win = app.window(class_name="Notepad")
win.get_by_role("Document").type_text("hello")
# app.kill() called automatically
Process lifecycle¶
app.wait_for_idle(timeout=10) # wait until CPU is idle
pid = app.process_id
app.close() # request graceful shutdown explicitly
app.kill() # deterministic teardown used by fixtures/context managers