Minimize all windows
-
Hi, thanks for looking I need to minimizee all maximized windows I tried this and it kind of works:
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each p As Process In Process.GetProcesses
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
Next
Me.WindowState = FormWindowState.Normal
End SubThe thing with this is that i dont want to iterate thru each process Now, im trying the sendkeys function to send Window + D to minimize all open windows, but i cant find the window representation, ive found this: SendKeys.Send("(^{ESC}{D})") But this doesnt do nothing on my pc, maybe because of my keyboard settings or something Does anyone have any other suggestions??
Alexei Rodriguez
-
Hi, thanks for looking I need to minimizee all maximized windows I tried this and it kind of works:
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each p As Process In Process.GetProcesses
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
Next
Me.WindowState = FormWindowState.Normal
End SubThe thing with this is that i dont want to iterate thru each process Now, im trying the sendkeys function to send Window + D to minimize all open windows, but i cant find the window representation, ive found this: SendKeys.Send("(^{ESC}{D})") But this doesnt do nothing on my pc, maybe because of my keyboard settings or something Does anyone have any other suggestions??
Alexei Rodriguez
Hi Alexei, Use the following code:
Public Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Public Sub MinimizeAll() keybd_event(&H5B, 0, 0, 0) keybd_event(&H4D, 0, 0, 0) keybd_event(&H5B, 0, &H2, 0) End Sub
The first line declares the API. Next piece of code is a method which we can call anywhere to minimize all windows... I hope this would be helpful.John Adams ComponentOne LLC. www.componentone.com
-
Hi Alexei, Use the following code:
Public Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Public Sub MinimizeAll() keybd_event(&H5B, 0, 0, 0) keybd_event(&H4D, 0, 0, 0) keybd_event(&H5B, 0, &H2, 0) End Sub
The first line declares the API. Next piece of code is a method which we can call anywhere to minimize all windows... I hope this would be helpful.John Adams ComponentOne LLC. www.componentone.com
Thanks for your answer, it works great I am trying to restore my window program after all wndows are minimized
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Timer1.Enabled = False
Me.MinimizeAll()
Me.WindowState = FormWindowState.Normal
End SubBut this doesnt work I tryed putting the current thread to sleep for a second, but didnt work either, it looks like keys are not being processed imediatelly, do you know of any workaround? All i need to do is to minimize all windows and restore the window of my program Thanks in advance
Alexei Rodriguez
-
Thanks for your answer, it works great I am trying to restore my window program after all wndows are minimized
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Timer1.Enabled = False
Me.MinimizeAll()
Me.WindowState = FormWindowState.Normal
End SubBut this doesnt work I tryed putting the current thread to sleep for a second, but didnt work either, it looks like keys are not being processed imediatelly, do you know of any workaround? All i need to do is to minimize all windows and restore the window of my program Thanks in advance
Alexei Rodriguez
I have a button with a call to the minimizeall method.
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MinimizeAll() Timer1.Interval = 500 Timer1.Enabled = True End Sub Private Sub Timer1\_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Enabled = False Me.WindowState = FormWindowState.Maximized End Sub
Works fine. that way. I tried your method and through the button click, but there is a timing issue with the minimizing and the maximizing. Break them out into sep routines and it works fine.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
-
I have a button with a call to the minimizeall method.
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MinimizeAll() Timer1.Interval = 500 Timer1.Enabled = True End Sub Private Sub Timer1\_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Enabled = False Me.WindowState = FormWindowState.Maximized End Sub
Works fine. that way. I tried your method and through the button click, but there is a timing issue with the minimizing and the maximizing. Break them out into sep routines and it works fine.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
Yes, enabling a timer to restore my window after the call to the minimize works fine I guess the keys are not imediatelly processed and calling thread.currentthread.sleep(1000) stops the whole app and makes no difference :( There must be some way to force the keys to be processed Thanks for the tip
Alexei Rodriguez
-
Yes, enabling a timer to restore my window after the call to the minimize works fine I guess the keys are not imediatelly processed and calling thread.currentthread.sleep(1000) stops the whole app and makes no difference :( There must be some way to force the keys to be processed Thanks for the tip
Alexei Rodriguez