Refresh Desktop: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Reverted edits by 208.79.14.20 to last version by Sag47) |
|
(One intermediate revision by one other user not shown) | |
(No difference)
|
Latest revision as of 21:54, 8 December 2008
Author: PeterSmith (talk, contrib) |
Description
Requires: System plug-in.
Refreshes the desktop window (USER32.DLL). This is required in the Windows 'Vista' operating system (as of the February 2005 'CTP' build). This script works by finding the correct desktop window and then posting a F5 virtual key down&up. The key sequence must use PostMessage; sending keystrokes using SendMessage doesn't work.
This script is presented as a standalone script; you can compile it into a standalone program or embed it into your script. Note that three user-defined variables are used.
The Script
Name RefreshDesktopWindow OutFile RefreshDesktopWindow.exe SilentInstall silent var ProgmanHwnd var ShellHwnd var DesktopHwnd Section "" ; 256=WM_KEYDOWN ; 257=WM_KEYUP ; 116=VK_F5 FindWindow $ProgmanHwnd "Progman" "Program Manager" FindWindow $ShellHwnd "SHELLDLL_DefView" "" $ProgmanHwnd 0 FindWindow $DesktopHwnd "SysListView32" "" $ShellHwnd 0 System::Call "user32.dll::PostMessage(i $DesktopHwnd, i 256, i 116, i 0)" System::Call "user32.dll::PostMessage(i $DesktopHwnd, i 257, i 116, i 0x80000000)" SectionEnd
Here is something much simpler
This refreshes Windows which is just as fast and in essence the same thing as refreshing the desktop (refreshes all windows).
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'