What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help running application on initialize

Pages: (2): « First [ 1 ] 2 » Last »
Help running application on initialize
Author: Message:
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. Help running application on initialize
Why doesn't the following code work for me. Debug says unterminated string constant
code:
function OnEvent_Initialize(MessengerStart)
{
new ActiveXObject("WScript.Shell").Run("\"C:\\Program Files\Windows Media Player\wmplayer.exe"");
}
}
01-17-2007 08:29 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help running application on initialize
All \ in Javascript need to be \\.

code:
function OnEvent_Initialize(MessengerStart) {
    new ActiveXObject('WScript.Shell').run('\\C:\\Program Files\\Windows Media Player\\wmplayer.exe');
}

This post was edited on 01-17-2007 at 08:31 PM by matty.
01-17-2007 08:30 PM
Profile E-Mail PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help running application on initialize
quote:
Originally posted by Matty
All \ in Javascript need to be \\.
* Jimbo hides in shame :$

Thanks!

This post was edited on 01-17-2007 at 08:33 PM by Jimbo.
01-17-2007 08:31 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Help running application on initialize
code:
.Run("\"C:\\Program Files\\Windows Media Player\\wmplayer.exe\"");

PS: try not to run an application on initialize if possible. The function initialize must return as quickly as possible and should do as little as possible. Instead use SignInReady or use a timer.

This post was edited on 04-10-2007 at 05:31 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-17-2007 09:20 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help running application on initialize
quote:
Originally posted by CookieRevised
code:
.Run("\"C:\\Program Files\\Windows Media Player\\wmplayer.exe\"");

PS: try not to run an application on initialize if possible. The function initialize must be return as quickly as possible and should do as little as possible
Thanks cookie i've changed it to OnEvent_Signin, but is there anyway to make it play automatically as well?
01-19-2007 07:03 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Help running application on initialize
code:

The MsgPlus::PlaySound function plays a sound asynchronously. It can also be used to stop the current sound from playing.

[boolean] PlaySound(
    [string] SoundFile
    [number,optional] MaxPlayTime
);

;) next time read your scripting doc....

that was in Objects Reference > MsgPlus Object > functions > Play Sound



edit: sorry it wasnt what you wanted :/

This post was edited on 01-19-2007 at 07:17 AM by NanaFreak.
01-19-2007 07:06 AM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help running application on initialize
quote:
Originally posted by NanaFreak
code:

The MsgPlus::PlaySound function plays a sound asynchronously. It can also be used to stop the current sound from playing.

[boolean] PlaySound(
    [string] SoundFile
    [number,optional] MaxPlayTime
);

;) next time read your scripting doc....

that was in Objects Reference > MsgPlus Object > functions > Play Sound
Thanks :p

EDIT: My code:
code:
function OnEvent_SigninReady(Email){
    new ActiveXObject('WScript.Shell').Run("\"C:\\Program Files\\Windows Media Player\\wmplayer.exe\"");
}

But what i want to do is when WMP runs i want to play a certain playlist and maybe even a random one each time it is run. Is this possible?

This post was edited on 01-19-2007 at 07:17 AM by Jimbo.
01-19-2007 07:09 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Help running application on initialize
With the Run function you start up an application. Most applications can take parameters and depending on what parameters you enter it does different stuff.

This is no different for WMP. What you do with the Run function is the same as what you do when you manually start a sound or playlist in Windows Explorer. In that case Windows will also start up WMP with a parameter, being the playlist for example.

What you also can do is starting up the playlist itself instead of starting up the WMP application. Windows will then automatically start that file with the associated application, which is in this case WMP. This is your best method for something like this because then you don't need to worry about the correct parameters (which can be quite different than just adding the filename to the command line) and Windows will handle all the rest for you.

So instead of Run("c:\wmplayer.exe") you do Run("c:\myplaylist.wpl"). The script should of course handle the randomness itself and needs a list (or directory) to choose the list from.

This post was edited on 01-19-2007 at 01:33 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-19-2007 01:30 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help running application on initialize
quote:
Originally posted by CookieRevised
With the Run function you start up an application. Most applications can take parameters and depending on what parameters you enter it does different stuff.

This is no different for WMP. What you do with the Run function is the same as what you do when you manually start a sound or playlist in Windows Explorer. In that case Windows will also start up WMP with a parameter, being the playlist for example.

What you also can do is starting up the playlist itself instead of starting up the WMP application. Windows will then automatically start that file with the associated application, which is in this case WMP. This is your best method for something like this because then you don't need to worry about the correct parameters (which can be quite different than just adding the filename to the command line) and Windows will handle all the rest for you.

So instead of Run("c:\wmplayer.exe") you do Run("c:\myplaylist.wpl"). The script should of course handle the randomness itself and needs a list (or directory) to choose the list from.
Thanks cookie, very useful as usual ;)

Why doesn't this code work then?
code:
function OnEvent_Signin(){
    new ActiveXObject('WScript.Shell').Run("\"C:\\Documents and Settings\\James Ross\\My Documents\\My Music\My Playlists\\Untitled Playlist.wpl\\"");
}

01-19-2007 07:33 PM
Profile E-Mail PM Find Quote Report
pedro_cesar
Junior Member
**

Avatar

Posts: 61
36 / Male / –
Joined: Dec 2006
Status: Away
RE: Help running application on initialize
'cuz u missed a \ in the route right before "My Playlist"

This post was edited on 01-19-2007 at 11:21 PM by pedro_cesar.
01-19-2007 11:20 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On