The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Vortex on January 01, 2011, 04:30:51 PM

Title: Minimizing open applications
Post by: Vortex on January 01, 2011, 04:30:51 PM
Here is how to minimize all open windows with the usage of COM :



.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\ole32.inc
include     MinimizeAll.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\ole32.lib

.data

CLSID_Shell   GUID sCLSID_Shell

IID_IDispatch GUID sIID_IDispatch


.data?

pShell         dd ?

.code

start:

    invoke      CoInitialize,NULL

    invoke      CoCreateInstance,ADDR CLSID_Shell,NULL,\
                CLSCTX_INPROC_SERVER,ADDR IID_IDispatch,ADDR pShell           

    coinvoke    pShell,IShellDispatch,MinimizeAll

    coinvoke    pShell,IShellDispatch,Release

    invoke      CoUninitialize
   
    invoke      ExitProcess,0

END start
Title: Re: Minimizing open applications
Post by: Vortex on January 01, 2011, 04:32:50 PM
Another version synthesizing the Windows key + M combination :



; Reference :

; http://support.microsoft.com/kb/194914/en-us

include MinimizeAllWnd.inc

.code

start:

    invoke  keybd_event,VK_LWIN,0,0,0

    invoke  keybd_event,'M',0,0,0

    invoke  keybd_event,VK_LWIN,0,KEYEVENTF_KEYUP,0
         
    invoke  ExitProcess,0

END start
Title: Re: Minimizing open applications
Post by: dedndave on January 01, 2011, 04:56:16 PM
very cool, Erol

now, i have more stuff to learn   :red
Title: Re: Minimizing open applications
Post by: caseys on January 01, 2011, 05:06:07 PM
good stuff =] thank you!