Sign in to follow this  
Followers 0
Overkill

forcing a window to be on top and active

10 posts in this topic

I've got a parent window ($MainGUI) and a child window ($AddItemGUI). Is there a way, besides using

If WinActive($AddItemGUI)=0 Then WinActivate($AddItemGUI)

to force the child window to be topmost *AND* always active (IE: force a user to close the GUI if they want to continue)?

Also, is there a way I can make the parent window inaccessible (but still visible) while the child window exists? Sometimes when I'm using a program, if I try to click the parent window of a child, the child window's title bar flashes and Windows makes an error sound, and the child window is still active. That's pretty much what I'm trying to achieve. There seems to be something at the OS-level that allows for this parameter to be set, but I don't see anything in Autoit that would accomplish it.

Thanks,

Overkill

Share this post


Link to post
Share on other sites



Hide the main window?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I've got a parent window ($MainGUI) and a child window ($AddItemGUI). Is there a way, besides using

If WinActive($AddItemGUI)=0 Then WinActivate($AddItemGUI)

to force the child window to be topmost *AND* always active (IE: force a user to close the GUI if they want to continue)?

Also, is there a way I can make the parent window inaccessible (but still visible) while the child window exists? Sometimes when I'm using a program, if I try to click the parent window of a child, the child window's title bar flashes and Windows makes an error sound, and the child window is still active. That's pretty much what I'm trying to achieve. There seems to be something at the OS-level that allows for this parameter to be set, but I don't see anything in Autoit that would accomplish it.

Thanks,

Overkill

Check out GUICreate's parent parameter in the Autoit help file.

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

Share this post


Link to post
Share on other sites

Also, is there a way I can make the parent window inaccessible (but still visible) while the child window exists?

GUISetState(@SW_DISABLE, $Parent)

You could also take a look at @SW_LOCK


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If you would like to create a child window without the ability to activate the parent window by clicking accidentally on it, or by switching with Alt+Tab, you must attach the child to the parent. That's the last parameter in the GUICreate() function.

$AddItemGUI = GUICreate("Add Item",800,600,-1,-1, 0, $WS_EX_TOPMOST, $MainGUI) ; the last option ,$MainGUI is here to make it a real child.

Hope this helps

Edited by charvi

Share this post


Link to post
Share on other sites

GUISetState(@SW_DISABLE, $Parent)

You could also take a look at @SW_LOCK

Will play with this in a bit...

Here's how I'm calling the functions at the moment:

$MainGUI = GUICreate("Startup List",400,650)
...
$AddItemGUI = GUICreate("Add Startup Item",380,200,Default,Default,$GUIOpts,$GUIOptsEx,$MainGUI)

The $GUIOpts and $GUIOptsEx are defined [appropriately] earlier.

The problem isn't putting and keeping the window on top - it's that I can't figure out for the life of me how to lockdown the app to force focus onto the child.

The goal of this app is to launch startup items, defined by the user, after windows has loaded; minimizing startup/login times. I've found it much easier to let Windows load and then run a batch file with my favorite applications in it...this will, ideally, provide the same benefit while increasing the functionality and ease of use =)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok - @SW_DISABLE did the trick. I probably should have dug that up, but meh...that's what you guys are for :) (jk).

Still looking for an alternative to the If-Then though.

Edited by Overkill

Share this post


Link to post
Share on other sites

Overkill

This?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Main GUI", 300, 200)
GUISetState(@SW_SHOW, $hGUI)

$hGUI_Child = GUICreate("Child GUI", 200, 100, -1, -1, -1, $WS_EX_TOPMOST, $hGUI)

GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE")

GUISetState(@SW_SHOW, $hGUI_Child)

GUISetState(@SW_DISABLE, $hGUI)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    Local $wActive = BitAND($wParam, 0x0000FFFF)
    
    Switch $hWnd
        Case $hGUI_Child
            If Not $wActive Then
                WinActivate($hGUI)
                WinActivate($hGUI_Child)
            EndIf
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

what ''0x0000FFFF'' stand for?

Share this post


Link to post
Share on other sites

oMBra

what ''0x0000FFFF'' stand for?

Zeroizes the left part, that is to say first 2 bytes. It's need to obtain the loWORD from the $wParam. :)

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  
Followers 0