Jump to content

Recommended Posts

Posted (edited)

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
        Case $HSHELL_WINDOWACTIVATED
            MsgPrint("Window activated: " & $lParam & " (" & WinGetTitle($lParam) & ")")
            $new = WinGetTitle($lParam)
    EndSwitch

    $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.


Mike

 

Edited by mbob61

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...