Today I am having difficulties with this following code:
x=msgbox("Your Text Here" ,0, "Your Title Here")
UserName=inputbox("After this message, you have 5 seconds to switch to Minecraft. Please enter the username you wish to type the song to:")
wscript.sleep 5000
WshShell.SendKeys "/msg" + UserName + "I know that we just met maybe this is dumb but it feels like there was something from the moment"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "that we touched 'Cause, it's alright, it's alright I wanna make you mine The way you're lightin'"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "up the room Caught the corner of my eye We can both sneak out the back door We don't have to say"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "goodbye 'Cause, it's alright, it's alright To waste time tonight Maybe I'm just a kid in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Maybe I'm just a kid in love Oh, baby If this is what it's like falling in love Then I don't ever"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "wanna grow up Maybe I'm just a kid in love Maybe I'm just a kid in love Oh, baby"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "It'd be cool if it's the two of us But I don't ever wanna grow up 'Cause I got it all"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Oh, oh, oh, oh, oh, oh And I got it all And I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Said, your place is kinda close And your 'Rents are out of town Baby, there's no pressure"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "But if you're down, I'm down 'Cause, it's alright, it's alright To just talk tonight"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "If you're feeling kinda crazy Turn down the lights We can take our time Do whatever you like"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "It's alright, it's alright I wanna make you mine Maybe I'm just a kid in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Maybe I'm just a kid in love Oh, baby If this is what it's like falling in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Then I don't ever wanna grow up Maybe I'm just a kid in love Maybe I'm just a kid in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Oh, baby It'd be fine if it's the two of us But I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "'Cause I got it all Oh, oh, oh, oh, oh, oh And I got it all And I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "'Cause I got it all Oh, oh, oh, oh, oh, oh And I got it all And I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "You make me feel like I got it all, yeah And you make me feel Like I'm just a kid in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "And you make me feel like I got it all And you make me feel like I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Maybe we're just kids in love Maybe we're just kids in love Oh baby If this is what it's like"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "falling in love Then we don't ever have to grow up Maybe we're just kids in love"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Maybe we're just kids in love Oh baby When we're alone and it's the two of us"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "I can't get enough I've got it all, yeah I've got it all, yeah"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "And I've got it, and I've got it all And I've got it, and we've got it all And I've got it,"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "and I've got it all But I don't ever wanna grow up"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Song: Kid In Love | By Shawn Mendes"
wscript.sleep 1000
WshShell.SendKeys "/msg" + UserName + "Sent by MineMessage (R) - By kittens643"
It is supposed to message a player in Minecraft this song, but this code is faulty. I have not done VBScript since last year, so this will be hard. Is / not allowed or is there a little typo?
Reading Windows Script Host SendKeys Method docs, all your characters are allowed except an unknown user's input.
However, set WshShell = WScript.CreateObject("WScript.Shell") missing in you code...
Consider testing it with notepad instead of Minecraft: all the code snippet outputs all in one line.
Related
Im making a game called cube, when I noticed a problem. I looked at Task Manager Fr Any Extra Programs, when I noticed tons of vbsscript running. I tried searching around, but no scripts worked for me. Heres my code (It plays A Sound)
Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "Sounds\Hurt.mp3"
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000
WScript.Quit 1
It still doesn't want to stop. Please Help.
Try the below example
With CreateObject("WMPlayer.OCX.7")
.URL = "C:\Users\DELL\Desktop\tmp\hit.wav"
.controls.play
Do
WScript.Sleep 100
Loop Until .playState = 1 Or .playState = 10
' .PlayState https://msdn.microsoft.com/en-us/library/windows/desktop/dd564085(v=vs.85).aspx
' "Stopped" (completed) or "Ready" (file not found)
End With
I'm looking to randomize a set of spoken phrases listed below so only one of them speaks each time the CD drive is ejected.
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
wscript.sleep 600000
do
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Randomize
CreateObject("SAPI.SpVoice").Speak "My life for Ire"
CreateObject("SAPI.SpVoice").Speak "I Love You"
CreateObject("SAPI.SpVoice").Speak "please, help me"
CreateObject("SAPI.SpVoice").Speak "Feed me"
CreateObject("SAPI.SpVoice").Speak "i am so alone"
CreateObject("SAPI.SpVoice").Speak "to arms my brothers"
CreateObject("SAPI.SpVoice").Speak "hey, listen."
CreateObject("SAPI.SpVoice").Speak "death to all"
CreateObject("SAPI.SpVoice").Speak "dum dee dee dum dee dum"
CreateObject("SAPI.SpVoice").Speak "the hunger is overwhelming"
CreateObject("SAPI.SpVoice").Speak "over here"
CreateObject("SAPI.SpVoice").Speak "dont ever leave me"
CreateObject("SAPI.SpVoice").Speak "duck duck goose"
CreateObject("SAPI.SpVoice").Speak "Autobots, roll out"
Next
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next
End If
Randomize
wscript.sleep Int(120000*Rnd)
loop
You can store all your message strings in an array. Then you can chose a random array index and thus get a different message every time.
Example Code (I left out some of your messages to avoid scrolling bars or line splitting but it works with any number of messages):
messages = Array("My life for Ire", "I Love You", "please, help me")
set oVoice = CreateObject("SAPI.SpVoice")
Randomize
msgNr = Int(((Ubound(messages)+1)*Rnd))
oVoice.Speak messages(msgNr )
Hi I am facing an issue setting a value in WebEdit field. I have identified the object. But unable to set the value in the field as the field has Ajax functionality.
Set WshShell = CreateObject("WScript.Shell")
Set webeditObj = webeditObject("class", "grid-dropdownbox", "index" , "0")
Browser(browserObj).Page(pageObj).WebTable(webtableObj).WebEdit(webeditObj).Click
Browser(browserObj).Page(pageObj).WebTable(webtableObj).WebEdit(webeditObj).Set refBook.Item("book")
wait(3)
WshShell.SendKeys "{DOWN}"
wait(1)
WshShell.SendKeys "{ENTER}"
wait(3)
I can see the value in the input box. But when going to the next field the value of previous field is getting cleared.
Please help.
The issue has been resolved.
Please refer the below code. But still the wait time is not 100% sure. Sometimes its failing.
Function setValue(browserObj, pageObj, webtableObj, webeditObj)
Set WshShell = CreateObject("WScript.Shell")
wait(3)
WshShell.SendKeys "{DOWN}"
wait(3)
Browser(browserObj).Page(pageObj).WebTable(webtableObj).WebEdit(webeditObj).Click
WshShell.SendKeys "{DOWN}"
wait(5)
WshShell.SendKeys "{ENTER}"
wait(3)
End Function
I am trying to get the system time in 24 hour format using VBScript. I had gone through the documents and found nothing. I need to compare the system date and time with my data and need to check the differences.
WScript.Echo right("0" & hour(time),2) & ":" & right("0" & minute(time),2)
WScript.Echo FormatDateTime(time, vbShortTime)
VBScript's Date datatype is format-agnostic. You can calculate the difference between the system time and some other timestamp using the DateDiff function, as long as VBScript recognizes the format of the other timestamp. Example (calculating the difference in seconds):
>>> systime = Now
>>> WScript.Echo systime
26.11.2013 12:48:52
>>> WScript.Echo DateDiff("s", systime, "11/25/2013 23:16:52")
-48720
>>> WScript.Echo DateDiff("s", systime, "25.11.2013 23:16:52")
-48720
This code gets me to the page and fills in the userid and password fields but after it does the submit I get a response from the application that the userid and password are not valid. If I don't execute the submit command but let the program stop at the page then manually click the login button then I successfully login. It appears eventhough the userid and paasword are being filled in correctly on the form, they are not getting passed through to the next page properly.
Any thoughts? I'm a VBsript newbie.
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://cpprod.stjohns.edu/cp/home/displaylogin"
Do
WScript.Sleep 500
loop While IE.ReadyState < 4 And IE.Busy
IE.Document.getElementByID("user").value = "testacct"
WScript.Echo IE.Document.getElementByID("user").value
IE.Document.getElementByID("pass").value = "testpw"
WScript.Echo IE.Document.getElementByID("pass").value
IE.Document.getElementByID("cplogin").submit
Give the below a try and let me know your results...
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.navigate WebPath
Do
WScript.Sleep 250
Loop While oIE.ReadyState < 4 And oIE.Busy
oIE.Document.All.Item("username").Value = sUser
WScript.Sleep 250
oIE.Document.All.Item("password").Value = sPass
WScript.Sleep 250
oIE.Document.All.Item("login").Click