Reputation: 610
I'm trying to create a batch script which opens Spotify and starts the playlist by sending the keypress spacebar
What I got is the following
start chrome.exe "https://play.spotify.com/chart/4rcbQSKQHID0UdZzODxg2Y"
sleep 8
WScript.CreateObject("WScript.Shell").SendKeys("{SPACE}");
which opens the browser with the mentioned website. Sadly nothing happens after that. Anybody got an idea how to solve this problem?
Upvotes: 0
Views: 667
Reputation: 41764
According to the SendKeys
documentation:
To send a space, send the string " ".
So you must send " "
instead of {SPACE}
WScript.CreateObject("WScript.Shell").SendKeys(" ");
More importantly, it's a Windows Script Host command so you can't run it directly in a batch file. You must store it in a separate vbs file and then run that file or use a hybrid batch-vbs file. Otherwise you'll get an error like this
'WScript.CreateObject'
is not recognized as an internal or external command, operable program or batch file.
Upvotes: 1