Results 1 to 9 of 9

Thread: How to open process in minimized state?

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    51

    How to open process in minimized state?

    Hello,

    I'm opening a process in my project to be set as a child window. Currently a timer is dictating when the process should be set (which is fine), however, because the tick interval is quite high (150ms), the window flashes on the screen before being set as child for a brief moment. Is there any way to open it in a minimized state so that it doesn't flash open outside of the panel before the next timer tick (which then sets it as child)?
    Also worth noting, the process starts, but the window only opens 15-25 seconds later (it's set as child when it's IsWindow - this is irrelevant I think for my question).

    What I've tried:

    Code:
    p = New Process
            With p
                .EnableRaisingEvents = True
                .StartInfo.FileName = "C:\myFile.exe"
                .StartInfo.WindowStyle = ProcessWindowStyle.Minimized
            End With
            p.Start()


    Thanks in advance.

  2. #2
    Addicted Member Goggy's Avatar
    Join Date
    Oct 2017
    Posts
    196

    Re: How to open process in minimized state?

    Could you try something like
    Code:
     Dim P As New ProcessStartInfo("c:\SomeFile.exe")
            P.WindowStyle = ProcessWindowStyle.Hidden
            Process.Start(P)
    Utterly useless, but always willing to help

    As a finishing touch god created the dutch

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    51

    Re: How to open process in minimized state?

    Thanks for the reply,

    However, using this code disables the application from even being set as child (for some reason). Also, it doesn't start in a min/hidden state.

    Thanks though

  4. #4
    Addicted Member Goggy's Avatar
    Join Date
    Oct 2017
    Posts
    196

    Re: How to open process in minimized state?

    Just tried you original code with notepad.exe and that seems to work by me...
    Can i ask what kind of file are you trying to start?

    Code:
     Dim P As Process = New Process
            With p
                .EnableRaisingEvents = True
                .StartInfo.FileName = "C:\Windows\Notepad.exe"
                .StartInfo.Windowstyle = ProcessWindowStyle.Minimized
            End With
            p.Start()
    Utterly useless, but always willing to help

    As a finishing touch god created the dutch

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    51

    Re: How to open process in minimized state?

    Hey,

    I'm trying to start a .jar file.

    Thanks.

  6. #6
    Addicted Member Goggy's Avatar
    Join Date
    Oct 2017
    Posts
    196

    Re: How to open process in minimized state?

    Not being formiliar with .jar extensions , i'm going to guess here.... that the file can't be run, it needs to be opend with an other program. something that the process will do.
    But now you need the program that opens the .Jar file to be minimized and NOT the .Jar file it self...

    I hope this makes sence to you :P
    Utterly useless, but always willing to help

    As a finishing touch god created the dutch

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    51

    Re: How to open process in minimized state?

    Quote Originally Posted by Goggy View Post
    Not being formiliar with .jar extensions , i'm going to guess here.... that the file can't be run, it needs to be opend with an other program. something that the process will do.
    But now you need the program that opens the .Jar file to be minimized and NOT the .Jar file it self...

    I hope this makes sence to you :P
    It makes sense, however that's definitely not the problem unfortunately

    Just a simple solution that I thought of, however I haven't learned how to do this yet, and I'm sure you (or anybody else) will know.

    Currently I'm setting the process as child - "If p IsNot Nothing AndAlso IsWindow(p.MainWindowHandle) [Then...]" under a timer tick sub. This is what's causing the issue. Is there a way for me to implement this same code under some other sub which doesn't rely on timer ticks. Because if so, it will be easy for me to implement the SendMessage function to minimize the process when it IsWindow and is something.
    Is there any way to do this without a timer tick event? But rather just, in general; when the window's there, do it immediately, rather than relying on the next tick event.

    I hope that makes sense, it's difficult for me to describe something that I don't (yet*) understand.

    Thanks for your help

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: How to open process in minimized state?

    Could you change the jar file to use JFrame#setState() so that the GUI comes up minimize automatically when it starts up (assuming you're using AWT or Swing)?

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    51

    Cool Re: How to open process in minimized state?

    Quote Originally Posted by passel View Post
    Could you change the jar file to use JFrame#setState() so that the GUI comes up minimize automatically when it starts up (assuming you're using AWT or Swing)?
    That's literally a perfect solution, however I don't know any Java and I'd only know how to decompile it. I wouldn't know how to edit it and then recompile it with a "main" class or whatever. I've tried with NetBeans IDE, but it was too damn complex.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width