After executing exe, it's not the active window

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
jplunkett
Posts: 6
Joined: Tue Dec 13, 2016 10:45 am

After executing exe, it's not the active window

Post by jplunkett » Tue Dec 13, 2016 10:48 am

Hi!

This is my first post and so far I've been able to find all the answer I need by myself, but this issue plagues me.

Once I build my script, everything works great except when I go to run the exe, a console window flashes and then I get my form, however, it's not the active window. :cry:

I've tried changing all the build options to windows forms with no luck.

Just don't know where to go from here, but I feel like it shouldn't be too hard.

Any help is appreciated!!

jvierra
Posts: 14010
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: After executing exe, it's not the active window

Post by jvierra » Tue Dec 13, 2016 11:08 am

Which "host" are you using to build the exe?

User avatar
jplunkett
Posts: 6
Joined: Tue Dec 13, 2016 10:45 am

Re: After executing exe, it's not the active window

Post by jplunkett » Tue Dec 13, 2016 11:26 am

Thanks for the reply!

I'm using SAPIEN PowerShell V5 Host (Windows Forms) x64

I've tried SAPIEN PowerShell V5 Host (Windows Forms) Win32 and SAPIEN PowerShell V5 Host (Windows) x64 with no success.

jvierra
Posts: 14010
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: After executing exe, it's not the active window

Post by jvierra » Tue Dec 13, 2016 11:35 am

Something in your PSF is opening a command window. Create a simple dialog form with no additions and build and run it. It should not give you a console window.

User avatar
jplunkett
Posts: 6
Joined: Tue Dec 13, 2016 10:45 am

Re: After executing exe, it's not the active window

Post by jplunkett » Tue Dec 13, 2016 11:55 am

I wonder if it's because I set some variables at the start of everything. They aren't wrapped in anything.

Let me move those around and see what happens.

User avatar
jplunkett
Posts: 6
Joined: Tue Dec 13, 2016 10:45 am

Re: After executing exe, it's not the active window

Post by jplunkett » Tue Dec 13, 2016 12:01 pm

Looks like that was it!

I had some code running at the top before the form loads.

So I'm just an idiot :D

Thank you very much for leading me in the right direction!

jvierra
Posts: 14010
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: After executing exe, it's not the active window

Post by jvierra » Tue Dec 13, 2016 12:06 pm

Not an idiot. It is a common error. Any direct output can cause a window to flash.

Locked