Link to home
Start Free TrialLog in
Avatar of Akire4
Akire4

asked on

Minimaze Application Window and Open Another Window

I'm running  a WinForms application  in windows7 OS that has two active windows and need to know how to accomplish this; How can I run from Active Window(1) a Shell -PowerShell script to minimize the window of this application where the Shell script will be run by clicking a command bottom and reopen (Maximize) the same application Window(2) that has been minimized before.

Thanks in advance...
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Let me get this straight you have a windows form application that creates a child window. and you want to minimize the parent window? all from a powershell script that runs externally to the application?
Avatar of Akire4
Akire4

ASKER

Yes, thanks for commenting to my question. I have an application that has a wizard type way of configuring the Forms functionality with controls that have some properties open to customize the Forms and I need someway of; when the application (it opens two Windows) opens from inside that application click a button to Minimize the Current active Form and maximize the other application window. This command button have two fields Command and Command Arguments to put a Shell.
Avatar of Akire4

ASKER

<you want to minimize the parent window?>
Yes, minimize Parent Window and maximize Child Window

<all from a powershell script that runs externally to the application? >
Yes, if I can call it from a command button inside this application and run a .PS1 file storage on the computer directory and...

No, if it can be run from inside this application Windows Form that have a command button that accept a Shell command Shell and Command Arguments.
Avatar of Akire4

ASKER

Im running an Application that opens two windows  and what I'm trying to accomplish is that when clicking a button on AppInstance_1 it will  minimized it and Maximize AppInstance_2 and vice versa

These sample code below can minimize Notepad, so how can I adapt this code to, let say I have tow Notepad files; File1.txt and file2.txt, how can modify the code below to when run minimize file1.txt and maximaze File2.txt. How can I reference the specific Instance name and not the application?

$sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
$hwnd = @(Get-Process Notepad)[0].MainWindowHandle
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)

Open in new window

Avatar of Akire4

ASKER

Can somebody tell me if I'm on the right Forum section???
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Akire4

ASKER

David, thanks your contribution to my post.

I'm new to this website, am I in the Scripting/PowerShell Forum?