Jump to content

How do I Set a window always ontop of only a specific window


Recommended Posts

I am trying to get my script to only appear ontop of a specific program.

But if I load another window, my script appears on top of that as well since it is ontop of everything.

My current work around is to make my script minimize using WinSetState ( "Hello world", "", @SW_HIDE ) whenever my window is not the active window.

However the problem is that when the specific program is still visible but not active(eg when popup windows activate), my script SW_HIDEs

Is there a better way of making program only stay ontop of the specific program instead of ontop of every window on my desktop?

Link to comment
Share on other sites

I am trying to get my script to only appear ontop of a specific program.

But if I load another window, my script appears on top of that as well since it is ontop of everything.

My current work around is to make my script minimize using WinSetState ( "Hello world", "", @SW_HIDE ) whenever my window is not the active window.

However the problem is that when the specific program is still visible but not active(eg when popup windows activate), my script SW_HIDEs

Is there a better way of making program only stay ontop of the specific program instead of ontop of every window on my desktop?

One simple way is to detect if the window you want to be above is active or not. If it is active then set your gui to be on top with WInSetOnTop($hGui,"",1).

If the window is not active then remove the topmost attribute for your gui with WinSetOnTopt($hGui,"",0) and then it will stay over the window as it was but another window can go over the top of your gui.

$meOnTop = False
While 1
    If WinActive("That other window", "") And $meOnTop = False Then
        WinSetOnTop($hGui, "", 1)
        $meOnTop = True
    EndIf
    If Not WinActive("That other window", "") And $meOnTop = True Then
        WinSetOnTop($hGui, "", 0)
        $meOnTop = False
    EndIf
    Sleep(200)
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

One simple way is to detect if the window you want to be above is active or not. If it is active then set your gui to be on top with WInSetOnTop($hGui,"",1).

That is a very clever solution! Thanks it works well.

Do you think not having the $meontop switch will slow down the script much? I left it out, so my script just keeps telling it to be on top over and over again without checking if my script is already on top.. seems fast enough for my use anyhow.

CHEERS!

Link to comment
Share on other sites

That is a very clever solution! Thanks it works well.

Do you think not having the $meontop switch will slow down the script much? I left it out, so my script just keeps telling it to be on top over and over again without checking if my script is already on top.. seems fast enough for my use anyhow.

CHEERS!

I suppose it will slow it down a bit, but I prefer not to set or unset things if there is no need.

Glad it worked for you.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

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