Bringing window to foreground (Java, SWT)

Last edited on

Overview

In general:

def main()
    o = waitForObject({"type": "org.eclipse.swt.widgets.Shell", "visible": "true"})
    o.forceActive()

Also see:

Additional settings for Linux

On Linux systems you may have to configure one of the following.

Ubuntu

Set the entry...

CompizConfig Settings Manager > General > General Options > Focus & Raise Behaviour > Focus Prevention Level

...to Off. (May require installing the CompizConfig Settings Manager.)

Other Linux distributions

Set the entry...

System Settings > "Window Behavior > Window Behavior > Focus > Focus stealing prevention level

...to None.

(German: "Fensterverhalten", "Fensterverhalten", "Aktivierung", "Vorbeugung gegen unerwünschte Aktivierung".)

Additional settings for Windows

On Windows you may have to configure the registry entry ForegroundLockTimeout ( google ForegroundLockTimeout ).

Reading the existing value in cmd.exe (Command Prompt):

reg query "HKEY_CURRENT_USER\Control Panel\Desktop" /v ForegroundLockTimeout

Setting (overwriting) the existing value in cmd.exe (Command Prompt):

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ForegroundLockTimeout /t REG_DWORD /d 0 /f

Notes

Bring Window to Foreground in Java AWT Swing