Taking this further, perhaps some of you will help with my coding. In user32.dll we can use GetDeskTopWindow to get a handle for the entire desktop window. The Windows API says: The GetDesktopWindow function retrieves the handle of the desktop window. The desktop window covers the entire screen and is the area on top of which all icons and other windows are painted. Then we can use LockWindowUpdate(hwnd) Here is my effort so far. [Warning to all: run at your own risk, bugs in this code can require a reboot.] Func GetDeskTopWindowHWND()
;I thought I should declare an array but it causes an error, so next line remmed out.
;Dim $DskTp[1]
;Get a window handle for the Desktop window
;WINAPI = HWND GetDesktopWindow(void)
;The GetDesktopWindow function retrieves the handle of the desktop window.
;The desktop window covers the entire screen and is the area on top of which all icons and other windows are painted.
$DskTp = DllCall("user32.dll", "", "GetDesktopWindow", "hwnd", 0)
Return $DskTp
EndFunc
Func LockDeskTopWindow($Dsk)
;Lock the HWND of the Desktop
;WINAPI = BOOL LockWindowUpdate(hwndLock)
$LckDskTp = DllCall("user32.dll", "int", "lockwindowupdate($Dsk)", "int", 0)
;return val = 0 = failure | nonzero = success
Return $LckDskTp
EndFunc
;Elsewhere in my code I have this function which uses the above two functions.
Func RemoveAllWindows(); This removes three windows by sending keys to menu items in an open application
$DskHwnd = GetDeskTopWindowHWND()
MsgBox(0,"RetVal", $DskHwnd & @CRLF&@error); Just checking all is well
LockDeskTopWindow($DskHwnd); I believe this works as a toggle and is repeated below to unlock the desktop window again, or else we must reboot! However, not working IMO
MsgBox(0,"RetVal", $DskHwnd & @CRLF&@error); Just checking all is well
WinWait("Harmonise! -- ","")
If Not WinActive("Harmonise! -- ","") Then WinActivate("Harmonise! -- ","")
WinWaitActive("Harmonise! -- ","")
WinMove("Harmonise! -- ","",$HarmWinPos[0],$HarmWinPos[1]); these have been set previously and help reset the open app. to its default position.
Send("!w2"); keys to close window 2
Send("!w3"); and 3
Send("!w4"); and 4
LockDeskTopWindow($DskHwnd); to unlock the desktop again.
MsgBox(0,"RetVal", $DskHwnd & @CRLF&@error); Just checking all is well
EndFunc Can any of you see how to improve this? DW