Jump to content
Sign in to follow this  

Application stealing focus

Recommended Posts


Hi everyone,

Medium term user, first time poster, love this language but I've finally found a problem which may have me stumped.

I have a java program which, when performing its functions, steals keyboard focus back. What I want is a way to disable this focus stealing while its minimized, but allow it to be opened and usable if clicked or alt-tabbed. Below is what I have so far:


if $new <> "" and $new <> $old Then $old = $new

    Switch $wParam
            MsgPrint("Window activated: " & $lParam & " (" & WinGetTitle($lParam) & ")")
            $new = WinGetTitle($lParam)

    $windowArray[0] = $old
    $windowArray[1] = $new

    if $new = 'MY_APP' and $old <> 'MY_APP' then WinActivate($old)

    What I have here nearly does the job as I would like. When MY_APP is the new app requesting focus, but another application has it, it cannot get it back.

However, I can no longer alt-tab or click the icon to bring it up, as the IF statement just activates the previous application again. I have tried many things, but have yet not found a solution which fill all the boxes.

Anyone got any idea? 
I was thinking of possibly ignoring the if statement if the user clicks an icon or uses ALT-TAB, but I can't work out a decent way to do this, and it doesn't seem very elegant.

tl;dr - Need a way to stop an app stealing focus on its own, but can be given focus whenever the user requires.



Edited by mbob61

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.