Jump to content
Sign in to follow this  
momar33

Hide window before it's opened

Recommended Posts

momar33

Is there a way to hide a window before it opens?

Right now i do a WinSetState() after i open the application, but that shows the window for a half second before hiding.

I would like for it the application that i am opening to never be seen.

Thanks

Share this post


Link to post
Share on other sites
weaponx

@SW_HIDE??

Share this post


Link to post
Share on other sites
mrbloody369

Is there a way to hide a window before it opens?

Right now i do a WinSetState() after i open the application, but that shows the window for a half second before hiding.

I would like for it the application that i am opening to never be seen.

Thanks

Here is an example of hideing the window then opening it.

ShellExecute("vlc", "", "C:\Documents and Settings\user\My Documents\vlc-0.8.6b-win32\vlc-0.8.6b\","", @SW_HIDE)
            while Not WinExists("VLC media player")
                Sleep(500)
            WEnd
            WinMove("VLC media player","", 0 , 0)
            WinSetState("VLC media player", "", @SW_SHOW)           
            Sleep(30)
            EndIf

Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button"

Share this post


Link to post
Share on other sites
momar33

Here is an example of hideing the window then opening it.

ShellExecute("vlc", "", "C:\Documents and Settings\user\My Documents\vlc-0.8.6b-win32\vlc-0.8.6b\","", @SW_HIDE)
            while Not WinExists("VLC media player")
                Sleep(500)
            WEnd
            WinMove("VLC media player","", 0 , 0)
            WinSetState("VLC media player", "", @SW_SHOW)           
            Sleep(30)
            EndIf

I tried this with calc.exe and it did nothing.

I have also tried using the @SW_HIDE with Run(), it doesn't seem to be working.

Share this post


Link to post
Share on other sites
Jos

I tried this with calc.exe and it did nothing.

I have also tried using the @SW_HIDE with Run(), it doesn't seem to be working.

This all depends on the actual application and is not something AutoIt3 can influence.

If the application decides to show a window initially then there is not much you can do other then to wait and hide it.

:)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ssubirias3

Is there a way to hide a window before it opens?

Right now i do a WinSetState() after i open the application, but that shows the window for a half second before hiding.

I too have been looking for a smoother and flicker free way of launching a hidden or minimized app. Even when @SW flags words with an app in the Run() command there can still be that split second flicker you're describing. Based on JdeB's answer it looks like we might be out of luck :).

I have also tried using the @SW_HIDE with Run(), it doesn't seem to be working.

Yeah I played around for a bit to see if any of the @SW flags would work with calc.exe but came up empty handed. Like JdeB said with some apps we have to wait and hide. Notepad unlike calc.exe works fine with @SW_HIDE in the Run() command. Here's the quick and crude code I played with if you're interested.

Opt("WinTitleMatchMode", 4)

Run("calc.exe", "", @SW_MINIMIZE) ;; <-- doesn't work either
Sleep(1500)
WinSetState("Calculator", "", @SW_HIDE)
Sleep(1500)
WinSetState("", "", @SW_SHOW)
Sleep(1500)
WinSetState("", "", @SW_MAXIMIZE) ;; <-- works despite not being an available command w/in calc.exe
Sleep(1500)
WinSetState("", "", @SW_RESTORE) ;; <-- works despite not being an available command w/in calc.exe
Sleep(1500)
WinSetState("", "", @SW_MINIMIZE)
Sleep(1500)
WinSetState("", "", @SW_RESTORE)
Sleep(1500)
WinClose("", "")
Sleep(1500)

MsgBox(0, "Up Next...", "Notepad Demonstration", 2)
Run("notepad.exe", "", @SW_HIDE)
Sleep(100)
ControlSetText("[Class:Notepad]", "", "[ClassNN:Edit1]", "abcdefg")
MsgBox(0, "Sent Text", '"abcdefg" to hidden notepad window', 3)
WinSetState("Untitled - Notepad", "", @SW_SHOW)
Sleep(1500)
WinSetState("", "", @SW_MAXIMIZE)
Sleep(1500)
WinSetState("", "", @SW_RESTORE)
Sleep(1500)
WinSetState("", "", @SW_MINIMIZE)
Sleep(1500)
WinSetState("", "", @SW_RESTORE)
Sleep(1500)
WinClose("", "")
Sleep(1500)
MsgBox(0, "Finished", "Thanks for playing!", 5)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.