If you have ever noticed in the Task Manager, when you right-click on the running task, you have many options which include 'Minimize' and 'Maximize'. Is there anyway to do achieve this in vb?
Here is an example of the code you are looking for. It will loop through all the active processes and minimize all the windows.
In your app you will probably want to use something like Process.GetProcessesByName
to find the specific window you want to manipulate.
Imports System.Runtime.InteropServices
Module ManipulateWindows
Const SW_HIDE As Integer = 0
Const SW_RESTORE As Integer = 1
Const SW_MINIMIZE As Integer = 2
Const SW_MAXIMIZE As Integer = 3
<DllImport("User32")> _
Private Function ShowWindow(ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
End Function
Public Sub Main()
'iterate through all the open processes.
For Each p As Process In Process.GetProcesses
'Get the Window Handle
Dim hWnd as integer = CType(p.MainWindowHandle, Integer)
'Write out the title of the main window for the process.
System.Console.WriteLine(p.MainWindowTitle)
'Minimize the Window
ShowWindow(hWnd, SW_MINIMIZE)
Next p
End Sub
End Module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With