Javascript WScript.SendKeys problem with Vista

Discussion in 'Internet Explorer' started by lcwakeman, Feb 9, 2007.

  1. lcwakeman

    lcwakeman Guest

    I am pretty sure that this is a problem with Vista and not I.E. but I have
    bni idea where in the Vista forums to post this. The following code works in
    XP with IE 6 and IE 7:

    function playFile(player, file)
    {
    var WshShell = new ActiveXObject("WScript.Shell");
    if (WshShell.AppActivate("Windows Media Player")) {
    WshShell.SendKeys('%FO');
    WshShell.SendKeys(file);
    WshShell.SendKeys('{ENTER}');
    } else {
    WshShell.Run('"'+player+'" "'+file+'"');
    }
    }

    It is called by passing in the fully specified (C:\...) location of the
    WIndows Media Player and an mp3 file that I want it to play. When the Media
    Player isn't running, it is started and the file plays. If the Media Player
    is running, it can't open the file. After some examination, the File Open
    Dialog box is dropping the first character of the file name (as in the C) and
    of course, WMP can't open ":/...". ANy Ideas?
     
    lcwakeman, Feb 9, 2007
    #1
    1. Advertisements

  2. lcwakeman

    lcwakeman Guest

    The following script works with Vista, it is a real kluge. Basicly if the
    app is running, I kill it and then run it again.

    function playFile(player, file)
    {
    var WshShell = new ActiveXObject("WScript.Shell");
    if (WshShell.AppActivate("Windows Media Player")) {
    WshShell.SendKeys("%Fx");
    }
    WshShell.Run('"'+player+'" "'+file+'"');
    }
     
    lcwakeman, Feb 19, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.