Sign in to follow this  
Followers 0
AutoChris

@SW_HIDE not working

11 posts in this topic

I don't know if this is a new issue or not because I do not recall ever having this problem before. I have been trying to run non-MS programs (Internet Explorer and the command prompt work fine) using the @SW_HIDE option and they are not running in hidden mode. I can wait until they are open and then WinSetState(..., ..., @SW_HIDE) and it works fine. However, my goal is not to hide the window after it appears, but to run it hidden.

Any ideas? Is anybody else having this problem?

Share this post


Link to post
Share on other sites



I don't know if this is a new issue or not because I do not recall ever having this problem before. I have been trying to run non-MS programs (Internet Explorer and the command prompt work fine) using the @SW_HIDE option and they are not running in hidden mode. I can wait until they are open and then WinSetState(..., ..., @SW_HIDE) and it works fine. However, my goal is not to hide the window after it appears, but to run it hidden.

Any ideas? Is anybody else having this problem?

Have you tried to use ShellExecute() rather than Run() with the @SW_HIDE option?

[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

Have you tried to use ShellExecute() rather than Run() with the @SW_HIDE option?

Yes, I tried to use ShellExecute as well, but it did not work either. I also thought that it may just be AutoIt on my computer that was having problems so I tried the same script on another computer and I had the same problem.

The program I am trying to get to run hidden is called DriverMax, which is a program to back up all of the drivers on your computer. However, I tried to run Firefox hidden as well--as a test--and it does not run hidden either.

Share this post


Link to post
Share on other sites

Yes, I tried to use ShellExecute as well, but it did not work either. I also thought that it may just be AutoIt on my computer that was having problems so I tried the same script on another computer and I had the same problem.

The program I am trying to get to run hidden is called DriverMax, which is a program to back up all of the drivers on your computer. However, I tried to run Firefox hidden as well--as a test--and it does not run hidden either.

I'm having a simualr problem although I'm not sure if its a badley coded prog that wont play rather than Autoit although I can make a shortcut which does work so I'm not sure.

Did you ever get a solution to this problem ?

Terran

PS Thought about running the shoutcut from Autoit but want to do the job properly really.

Share this post


Link to post
Share on other sites

Some applications just don't respect the window state flag. Like Calc - even from a shortcut. It's beyond me how this is possible, but it might be that Windows is somehow more awesome than it seems to be.

What you could maybe do, at least to make it look nice while you are waiting for the application to start so you can hide it, is use SplashImageOn to pop up a graphic. It's a "on top" window, so your app should show up behind it - presuming your app isn't setting itself on top too.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Larry, that's somewhat disconcerting. :whistle: How might an AutoIt gui go about checking whether or not to show itself? Some sort of DllCall into Shell32, I'd expect, but I don't see a GetVisibilityFlag anywhere...


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

compile this

GUICreate("test")
GUISetState()
Sleep(5000)

then try to @SW_HIDE it from a Run()... @SW_HIDE may ave a narrower audience than you might think.

Lar.

I'll give this a go... but in the mean time here is a few comments from another fellow coder who did the same but in Delphi 7.... although I'm not up on Delphi to me the commands look very simular. Now this does work which is leading me to the belife that @SW_HIDe needs looking at by the Autoit programmers ?

Hope its of some use.

The version of the code he posted has a 'mode' setting in the ini file which is used as follows:

0 - should behave like my original version

1 - minimized

2 - maximized

3 - hidden

any other value - like my original version

The mode value is used to set a parameter to the createprocess call. So you need to call CreateProcess with the same parameters from autoit to replicate the behaviour.

The relevant code is:

getstartupinfo(si);
          si.cb:=sizeof(si);
          si.wShowWindow := SW_SHOWNORMAL;
          si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
          case fmode of
            0:si.wShowWindow := SW_SHOWNORMAL;
            1:si.wShowWindow := SW_SHOWMINIMIZED;
            2:si.wShowWindow := SW_SHOWMAXIMIZED;
            3:si.wShowWindow := SW_HIDE;
          else
            si.wShowWindow := SW_SHOWNORMAL;
          end;
          res := createprocess(pchar(fprog), '', nil, nil, false, 0, nil, nil, si, pi);

The si parameter is the one that controls window visibility

This is what I am using....

CODE
; Read $runs - If = hd then @SW_HIDE - If mn then @SW_MINIMIZE - If mx then @SW_MAXIMIZE then sets $runs2 correct variable

If $runs="hd" Then $runs2="@SW_HIDE"

If $runs="mn" Then $runs2="@SW_MINIMIZE"

If $runs="mx" Then $runs2="@SW_MAXIMIZE"

You can find the full source here..... http://www.letscommunicate.co.uk/carputer/...tinethelper.zip

Terran

Share this post


Link to post
Share on other sites

If all fails, perhaps consider using the sloppier way:

WinSetTrans(.., .., 0)

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

If everything is failing, you might consider running a /AutoIt3ExecuteScript right before your Run() command, that waits for the window, then hides it, it would almost be instant I would think.


[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

If everything is failing, you might consider running a /AutoIt3ExecuteScript right before your Run() command, that waits for the window, then hides it, it would almost be instant I would think.

Never thought of that.

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

I could but I'm letting the user set any exe to execute via an ini file plus thats not really neat when that command should do that... so I thought.

Terran

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