Sign in to follow this  
Followers 0
kiboost

window Z order ?

7 posts in this topic

#1 ·  Posted (edited)

I'm coding a starter app that start some other software, but before it check if it is launched and if it is, it activate its window.

My problem is that I got some strange behavior, sometimes winactivate pop the windows on top of others (I don't talk about 'allways on top' option), sometimes it blink but stay in background.

For example :

Func _launchXX()
    _Done();;close my gui
    If ProcessExists ( "XX.exe" ) Then
        WinActivate("XX window", "")
    Else
        ShellExecute("C:\mypath\XX.exe")
        WinActivate("XX window", "")
    EndIf
EndFunc

In this example, if xx is started, the window comes to foreground. But if not, it start it, and it stay in background, even after having add a winactivate !

So is there a way or another function to allways set a window to absolute top of all others (but not allways on top...) ?

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites



On the Else statement, you are trying to activate the window before the application has a chance to launch. Try ShellExecuteWait.


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

sleepydvdr

ShellExucuteWait() ?, that's a blocking function (until the shell is closed again -> no shell window to.)

kiboost

Your script is not waiting for the window to be created by the target shell/Appl.

Drop a WinWait() between your ShellExecute() and WinActivate(), so your script waits for it.

(Or replace WinActivate() by WinWait(). See Doc for other WinWait* variants.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

sleepydvdr

ShellExucuteWait() ?, that's a blocking function (until the shell is closed again -> no shell window to.)

kiboost

Your script is not waiting for the window to be created by the target shell/Appl.

Drop a WinWait() between your ShellExecute() and WinActivate(), so your script waits for it.

(Or replace WinActivate() by WinWait(). See Doc for other WinWait* variants.)

You are correct. I don't know what I was thinking there.


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

ok will try that.

But sometimes even winactivate on an existing window doesn't bring the window to front. That's why I was looking for other, more ribust, solution.

other example :

Run("explorer.exe "&$mypath)

sometimes it open a new file explorer in front, sometimes open the new one behind a window (scite for example).


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

How about using @SW_SHOW?

ShellExecute("explorer.exe", "c:\", "", "", @SW_SHOW)

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

How about something more like this:

Func _launchXX()
    If Not ProcessExists( "XX.exe" ) Then ShellExecute("C:\mypath\XX.exe")
    $hWin = WinWait("XX window", "")
    WinActivate($hWin)
EndFunc

:mellow:


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