Sign in to follow this  
Followers 0
ZoScr

Showing (unhiding) an always-on-top window without it grabbing focus

6 posts in this topic

On certain events, my AutoIt script positions its hidden window (which includes $WS_POPUP, $WS_EX_TOPMOST & $WS_EX_TOOLWINDOW), then unhides it via GUISetState(@SW_SHOW).

Whatever non-AutoIt application previously had the focus loses the focus to my AutoIt script. This is undesireable to me.

Is there a way to prevent this? Or a way to instantly activate the window that previously had the focus?

My script basically pops up a balloon (but can't use ToolTip or TrayTip because of the nature of the content) and I want to be able to see it when it comes up (hence the always-on-top attribute) but not have it interfere with whatever else I'm doing.

Any suggestions? I searched the forum a bit but didn't come up with anything.

Thanks!

Share this post


Link to post
Share on other sites



If Not WinActive('My Script') Then WinActivate('My Script')
?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

That's the opposite of what I'm looking for. The problem is, my script is taking the focus upon my unhiding it, and I don't want it to. I want up there and visible but not activated.

I've been trying this out:

http://www.autoitscript.com/forum/index.ph...533;entry197848

The results are interesting, but disappointing. When my script processes the WM_ACTIVATEAPP, in the situation in question (when the app grabs the focus on its own, without being clicked), when wParam correctly indicates TRUE, lParam oddly contains 0.

lParam will have data in it when I take the app back away from my app (and thus wParam is FALSE), and will also have data when I cause my app to get focus by clicking on it. But, just a 0 when I need data the most.

I played around with a Windows message spying utility for a bit, and it seemed to see data in the lParam field in that case. So, a mystery...

Share this post


Link to post
Share on other sites

I seem to have solved my problem with a little bit of a hack:

I determined that only the GUISetState(@SW_SHOW) call was grabbing the focus (and not my calls to WinMove() or WinSetTrans()).

So, instead of calling GUISetState(@SW_SHOW) to unhide and GUISetState(@SW_HIDE) to hide, now I instead leave the window unhidden, and toggle the transparency between 0 (invisible) and my desired value. This seems to be working!

Share this post


Link to post
Share on other sites

Seems you already found a solution, but I think this is what you want:

GuiSetState(@SW_SHOWNA)
->

Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated.

Note: I've not tested this.

Alzo


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

Seems you already found a solution, but I think this is what you want:
GuiSetState(@SW_SHOWNA)oÝ÷ ÚM¢×ßÛÞmzË^vØb°   s£ú®¢×¢wÜZv}ý¶z-Ç­«lµ«^§+¡·¢·zË^uø§{­«­¢+ØìQÍÐÕ¥MÑMÑÑ ¤)U%
ÉÑ ÅÕ½ÐíQÍÐÅÕ½Ðì¤)U%MÑMÑÑ¡M]}M!=]9¤)ͱÀ ÔÀÀÀ¤)5Í   ½à ÌÈ°ÅÕ½ÐíQÍÐÅÕ½Ðì°ÅÕ½Ðí½¹üÅÕ½Ðì

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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