views:

183

answers:

2

Hello,

here is my next question and i hope some one can help me :-)

Is it possible to position a msgbox in wsh/vbs?

alt text

I need the msgbox everytime in the foreground. I know that how to position a inputbox, but not a msgbox.

Thanks for help.

Greetings, matthias

+1  A: 

This is possible. Here is a link to a code sample (VB5, so it should work for you):

http://support.microsoft.com/kb/180936

Basically, you set up a hook so that your application gets a notification whenever you pop up a message box. Inside the handler, you move the message box to the desired location on the screen.

MusiGenesis
Thanks. But my problem is, i know not so mutch about vb5. I don't know how to customized for my vbs program.My script looks like this:MsgBox "Kill program"wscript.quit
matthias
My bad. I didn't realize you can't call the Win32 API directly from VBS. I'm pretty sure you could create a Visual Basic 5.0 DLL that wraps the MsgBox function (with custom positioning) and then call it from your VBS program. I do not know how to do this myself anymore (I haven't done VB in about 10 years), but you could ask this question here on StackOverflow and probably get some good answers.
MusiGenesis
+2  A: 

You cannot do that with a WSH MsgBox using VBS alone.

InputBox is the only build in dialog function that allows you to set a position.

You can use a WshShell.Popup and make it disappear after a few seconds, however it will be centered.

Edit; here is something using IE.

Alex K.
can you give me an example?
matthias
`Set WshShell = CreateObject("WScript.Shell")if WshShell.Popup("I display for 5 seconds", 5, , 4) = 6 then msgbox "yes clicked"`or`x = inputbox("aaa", "bbb", "ccc", 100, 100)`
Alex K.
ok thanks it works
matthias