0

We just got a new win 7 64 computer and one very old program does not display properly on launch - it doesn't draw itself completely until I change the size of its window. I'd like to write a small script program that launches the old program, then changes its size (for example, minimize then restore or maximize then restore its window) or otherwise forces the program to redraw itself.

That way a user could click on the program icon and it would flicker a moment and display properly.

I tried:

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""c:\Program Files (x86)\VideoLan\VLC\vlc.exe""")
objShell.SendKeys "% x"
objShell.SendKeys "% r"
Set objShell = Nothing

Based on How can I maximize, restore, or minimize a window with a vb script? That worked to launch vlc (test program, not the problem program), but did not change its size.

EDIT: adding a slight delay after run (wscript.sleep(200)) fixed the problem. I'd still like to know if there's a better way.

Community
  • 1
  • 1
foosion
  • 7,619
  • 25
  • 65
  • 102
  • I think the way to go would be: 1) Get the window handle of the window (you should be able to do this by getting the process you just created from the windows API and then getting the handle of the main window) 2) Send a WM_PAINT message to the window. May I ask if you are using an english version of windows? – Emiswelt Feb 23 '13 at 09:53
  • Please expand on how to do this. I am running the english version of windows – foosion Feb 23 '13 at 10:01

1 Answers1

0

Not sure if this will work, but you could give it a try:

CreateObject("Shell.Application").Namespace(0).Self.InvokeVerb "R&efresh"

The above invokes a "Refresh" of the desktop, which may or may not update your application window as well.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328