Jump to content

@SW_HIDE not working


Recommended Posts

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?

Link to comment
Share on other sites

  • Moderators

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?

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.

Link to comment
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.

Link to comment
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.

Link to comment
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]

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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..

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...