Archive: Refresh with SendMessage


Refresh with SendMessage
Hi all,

I previously asked questions about SendMessage (for those interested: I have a fight with Matlab: it doesn't understand my messages amd I don't understand it's output so we've broken up and I tried something else to install a plugin into Matlab... and succeeded :)).

But now: how to refresh the desktop (like F5)? My little program created in NSIS edits some HTML page on the Active Desktop (Windows) and I need to refresh the desktop to load this page.

Is it possible using SendMessage. How?

Thx, greetz, Hendri.


Nice that you've found a solution for your problem :)

The refresh thing should work when you send an WM_SETTINGCHANGE with the hwnd HWND_BROADCAST.

Since WM_SETTINGCHANGE resolves to 26 and HWND_BROADCAST to 0xFFFF a call to

SendMessage 65535 26 0 0
should do the job.

~ Florian

Florian, thx a lot,

it works great!!!

Thx, thx, thx, greetz,
Hendri.


Florian, sorry,

for a minnute it appeared to work great, because my screen flashed,
but after implementing this into the HTML editor for my active desktop I saw that only the desktop gets a refresh, except my Active Desktop (the HTML doc).

How to refresh this one then? (And maybe also ONLY this one if possible...)

Can you help me, thx, greetz,
Hn3.


If NSIS can exec an external vbscript, I've got the answer.

I did have the script writing to the registry and refreshing the desktop, but it just wasn't updating to display the new page. this code does it. To test, just create a dummy HTML page and set it in your %systemroot%\web\wallpaper directory, then change the script to point to the correctly named page.

Running the script will set the desktop, open the display properties window, move the selection up/down, then click the OK button. It's dirty, but it gets done!

****************************************
BEGIN CODE
****************************************
' Create the variables needed
Dim WSHShell
Dim WSHApp
Dim strRegKey
Dim strWallpaper
Dim strOSRoot
Dim strDesktop
Dim strDisplayProp

' Create the Wscript Shell object
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHApp = CreateObject("Shell.Application")

' Define the wallpaper
strWallpaper = "%SystemRoot%\Web\Wallpaper\PRWeb.html"
strDesktop = WSHShell.SpecialFolders("Desktop")
strDisplayProp = "Display Properties"

' Create the wallpaper key
strRegKey = "HKEY_CURRENT_USER\"
strRegKey = strRegKey & "Software\"
strRegKey = strRegKey & "Microsoft\"
strRegKey = strRegKey & "Internet Explorer\"
strRegKey = strRegKey & "Desktop\"
strRegKey = strRegKey & "General\"
strRegKey = strRegKey & "Wallpaper"

' Write the key, type, and value
WSHShell.RegWrite strRegKey, strWallpaper, "REG_EXPAND_SZ"

WSHApp.ControlPanelItem cstr("desk.cpl")
Do Until WSHShell.AppActivate (strDisplayProp)
Loop
WSHShell.SendKeys "{down}{up}{tab 3}a~"
****************************************
END CODE
****************************************

The only problem you might have is with a virus scanner - it'll throw up an alert as soon as you try to run a .vbs file. Hope that helps!