Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimizing all running applications??? 3

Status
Not open for further replies.

Gert

Programmer
Apr 9, 2000
240
DO
Hi all, could be some way to Minimize all running applications, or at least the ones i choose.

thanks in advance!!
 
thanks ramani, that's excelent
 
Gert,

Cut-n-paste the code below into a prg file and run it from within VFP...

DECLARE INTEGER CloseWindow IN user32 INTEGER
DECLARE INTEGER GetActiveWindow IN user32
DECLARE INTEGER GetWindow IN user32 INTEGER, INTEGER
DECLARE INTEGER GetWindowTextLength IN user32 INTEGER
DECLARE INTEGER IsIconic IN user32 INTEGER
DECLARE INTEGER IsWindow IN user32 INTEGER
DECLARE INTEGER IsWindowVisible IN user32 INTEGER

LOCAL nActive, nCounter, nHwnd, nIndex
LOCAL cWindowCaption

nCounter = 0
nHwnd = -1

nActive = GetActiveWindow()

DO WHILE nHwnd != GetWindow(nActive, 1) &&1 = FIRST WINDOW
IF nHwnd != -1
nHwnd = GetWindow(nHwnd, 2) &&2 = NEXT WINDOW
ELSE
nHwnd = GetWindow(nActive, 0) &&0 = LAST WINDOW
ENDIF

IF GetWindowTextLength(nHwnd) > 0 AND IsWindow(nHwnd) != 0 AND IsWindowVisible(nHwnd) != 0
nCounter = nCounter + 1
DIMENSION aryWindows(nCounter)
aryWindows(nCounter) = nHwnd
ENDIF
ENDDO

*!* Now Minimize All Windows
FOR nIndex=1 TO nCounter
If IsIconic(aryWindows(nIndex)) = 0
IF CloseWindow(aryWindows(nIndex)) = 0
*!* Window doesn't exist or something wrong
ENDIF
ENDIF
ENDFOR

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
thanks slighthaze, work great
 
Just for fun, you can get the same result in Explorer by pressing WINKEY+M. Here's the code that does that:

Declare keybd_event in User32 ;
Short bVK, Short bScan, Long nFlags, Long dwExtraInfo

keybd_event(0x5B, 0, 0x01 , 0 ) &&press WinKey
keybd_event(0x4D, 0, 0x01 , 0 ) && press M
keybd_event(0x4D, 0, 0x03, 0 ) && release M
keybd_event(0x5B, 0, 0x03, 0 ) && release WinKey

Credit (& compliments) to Aircon for this solution.
Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top