Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Minimize all windows

Minimize all windows

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexeiXX3
    wrote on last edited by
    #1

    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 Sub

    The 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

    J 1 Reply Last reply
    0
    • A AlexeiXX3

      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 Sub

      The 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

      J Offline
      J Offline
      John Ad
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • J John Ad

        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

        A Offline
        A Offline
        AlexeiXX3
        wrote on last edited by
        #3

        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 Sub

        But 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

        J 1 Reply Last reply
        0
        • A AlexeiXX3

          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 Sub

          But 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

          J Offline
          J Offline
          Jon_Boy
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • J Jon_Boy

            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.

            A Offline
            A Offline
            AlexeiXX3
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • A AlexeiXX3

              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

              J Offline
              J Offline
              JR212
              wrote on last edited by
              #6

              Take a look here http://www.codeproject.com/KB/system/Hotkeys.aspx[^]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups