kiboost Posted August 2, 2011 Share Posted August 2, 2011 (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 August 2, 2011 by kiboost Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79 Link to comment Share on other sites More sharing options...
sleepydvdr Posted August 2, 2011 Share Posted August 2, 2011 On the Else statement, you are trying to activate the window before the application has a chance to launch. Try ShellExecuteWait. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
MvGulik Posted August 2, 2011 Share Posted August 2, 2011 (edited) sleepydvdrShellExucuteWait() ?, that's a blocking function (until the shell is closed again -> no shell window to.)kiboostYour 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 August 2, 2011 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 ... Link to comment Share on other sites More sharing options...
sleepydvdr Posted August 2, 2011 Share Posted August 2, 2011 sleepydvdrShellExucuteWait() ?, that's a blocking function (until the shell is closed again -> no shell window to.)kiboostYour 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> Link to comment Share on other sites More sharing options...
kiboost Posted August 2, 2011 Author Share Posted August 2, 2011 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 Link to comment Share on other sites More sharing options...
sleepydvdr Posted August 2, 2011 Share Posted August 2, 2011 How about using @SW_SHOW? ShellExecute("explorer.exe", "c:\", "", "", @SW_SHOW) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 2, 2011 Share Posted August 2, 2011 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 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now