How can I make a VBS Message Box appear in a random place?

这一生的挚爱 提交于 2021-02-19 08:09:26

问题


In VBS script, I have created a simple message box application. It currently stays in front of all windows until the user responds and uses very simple coding

    X=MsgBox("Test Text" ,1+4069, "Test Title")

But it always appears in the same place. Is there any way of making it appear in a random place on the screen? Please help!


回答1:


There is one type of box which allows you to position it on the screen: InputBox

Title = "Hello"
DefaultValueText = "Hello Stackoverflow !"
message = "Type something here"
XPos = 0
YPos = 0
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)
XPos = 3000
YPos = 800
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)



回答2:


@Hackoo was almost there, I used his and here is what I made out of it.

dim r
randomize
r = int(rnd*500) + 1
r2 = int(rnd*1500) + 1
Title = "Hello"
DefaultValueText = "Hello!"
message = "Type something here!"
XPos = r
YPos = r2
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)


来源:https://stackoverflow.com/questions/37111397/how-can-i-make-a-vbs-message-box-appear-in-a-random-place

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!