Minimizing Windows on the Desktop

The following two programs both minimize all the active windows on the desktop by 'faking' the 'Left-Window', and 'M' keyboard combination. The only difference is in the way that the program's window is restored.

The first example calls ShowWindow() with the SW_RESTORE flag,
.. and the second example uses a call to the
OpenIcon() function to do the same.

Of course, if you just want to minimize all the Desktop windows, just don't call these functions... '-)

-- min_all_but1.exw

include win32lib.ew

constant
win1=create( Window, "Minimize all but me...1", 0, 100, 100, 300, 150, 0 ), 

-- constants,  and functions not in win32lib,  yet !
KEYEVENTF_KEYUP = 2, 
MinimizeAll = 77, 
zkeybd_event=registerw32Function(  user32, 
             "keybd_event",  { C_INT,  C_INT,  C_INT,  C_INT },  C_INT  )

----

procedure minimize_all(  integer self,  integer event,  sequence params  )
    atom jk
    showWindow( win1,  True  )
    sleep( 1 )
    showWindow( win1,  False  )
    jk = w32Func( zkeybd_event,  {VK_LWIN,  0,  0,  0 }  )
    jk = w32Func( zkeybd_event,  {MinimizeAll,  0,  0,  0 }  )
    jk = w32Func( zkeybd_event,  {VK_LWIN,  0,  KEYEVENTF_KEYUP,  0 }  )
    sleep( 2 )
    jk = w32Func(  xShowWindow,  {getHandle( win1 ),  SW_RESTORE}  )
end procedure
setHandler(  win1,  w32HOpen,  routine_id( "minimize_all" )  )


WinMain(win1,Normal)

--------

... and, here's the second example.

-- min_all_but2.exw

include win32lib.ew

constant
win1=create( Window, "Minimize all but me...2", 0, 100, 100, 300, 150, 0 ), 

KEYEVENTF_KEYUP = 2, 
MinimizeAll = 77, 
zkeybd_event=registerw32Function(  user32, 
             "keybd_event",  { C_INT,  C_INT,  C_INT,  C_INT },  C_INT  ), 
zOpenIcon=registerw32Function(  user32, 
          "OpenIcon",  {C_INT},  C_INT  )


procedure minimize_all(  integer self,  integer event,  sequence params  )
    atom jk
    showWindow( win1,  True  )
    sleep( 1 )
    showWindow( win1,  False  )
    jk = w32Func( zkeybd_event,  {VK_LWIN,  0,  0,  0 }  )
    jk = w32Func( zkeybd_event,  {MinimizeAll,  0,  0,  0 }  )
    jk = w32Func( zkeybd_event,  {VK_LWIN,  0,  KEYEVENTF_KEYUP,  0 }  )
    sleep( 2 )
    jk = w32Func( zOpenIcon,  {getHandle( win1 ) }  )
end procedure
setHandler(  win1,  w32HOpen,  routine_id( "minimize_all" )  )

WinMain(win1,Normal)

--------

..end of lesson.

CONTENTS