background preloader

Vbscript MessageBox

Facebook Twitter

How Can I Center an HTA on the Screen? - Hey, Scripting Guy! Blog. Hey, Scripting Guy!

How Can I Center an HTA on the Screen? - Hey, Scripting Guy! Blog

How can I center an HTA on the screen? -- BH Hey, BH. Well, we have an answer for you, although it’s not perfect: we can resize (if need be) and center your window, but there will be a momentary flash on the screen when all this happens. It’s not too terribly distracting and the net effect is what you want: the HTA will be centered on screen. Here’s the code for our sample HTA. <html><head><title>Centered HTA</title><HTA:APPLICATION ID="objHTA" APPLICATIONNAME="Centered HTA" SCROLL="yes" SINGLEINSTANCE="yes" ></head><SCRIPT Language="VBScript"> Sub Window_Onload strComputer = ".

" Start this HTA and - after a brief flash - the window will be resized to 800 pixels by 600 pixels, and will be centered onscreen. Good question: what is going on here? After connecting to the Win32_DesktopMonitor class we then use these two lines of code to determine the current screen dimensions: intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight window.resizeTo 800,600. How Can I Specify a Window Size for My HTA? - Hey, Scripting Guy! Blog. Hey, Scripting Guy!

How Can I Specify a Window Size for My HTA? - Hey, Scripting Guy! Blog

How can I specify a particular window size for my HTA? -- RN Hey, RN. We can’t speak for Dear Abby, Ann Landers or any other daily columnist, but the Scripting Guys are always on the lookout for a question that can be answered using a single line of code. That’s the Holy Grail for daily columnists: one and done. And now we have. Window.resizeTo 400,250 There you go: add that line of code to your HTA and the next time you start the thing the window will automatically be sized to 400 pixels wide by 250 pixels high. What’s that? Sub Window_onLoad window.resizeTo 400,250 End Sub As you probably know, Window_onLoad is a special subroutine designed to run any time the HTA starts up or is refreshed. Here’s a more “complete” HTA, one that does nothing other than show up in a window 400 pixels by 250 pixels: <SCRIPT LANGUAGE="VBScript"> Sub Window_onLoad window.resizeTo 400,250 End Sub </SCRIPT><BODY></BODY> But do us a favor, OK?

How Can I Display a Message Box That Has No Buttons, and That Disappears After a Specified Period of Time? - Hey, Scripting Guy! Blog. Hey, Scripting Guy!

How Can I Display a Message Box That Has No Buttons, and That Disappears After a Specified Period of Time? - Hey, Scripting Guy! Blog

I would like to display a message box for a set amount of time and then have it disappear. However, I’d prefer that this message box not have a close button, or have anything else that would allow the user to close the message, minimize the message, etc. How can I do that? -- D Hey, D. The first time we told people they couldn’t do something and then immediately turned around and told them how to do it, well, that was pretty cute; by the 138th time, hwoever, it wasn’t quite so cute anymore. Which didn’t make Peter all that happy, considering the fact that he’s still very much alive. So instead of saying that you can’t display a message box that doesn’t have a button on it (and then – after dashing your hopes – telling you that we have a workaround anyway) we’ll just talk about something else.

Oh, what the heck: the truth is, D, you can’t display a message box (for any amount of time) that doesn’t include a button of some kind. So what kind of workaround do we have?