A little help - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: A little help (/showthread.php?tid=87815)
A little help by Shi-Kami on 12-18-2008 at 02:12 AM
Im new here, and new to this scripting...
Just a small problem
jscript code: function _start_app(_path){
new ActiveXObject('WScript.Shell').run(_path);
}
function upd8(Wnd, Params){
var Url = "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"
var OutFile = MsgPlus.ScriptFilesPath + "\\NameChanger.v1.20.plsc"
var File = MsgPlus.DownloadFile(Url, OutFile);
if(File){
Debug.Trace("Downloading file, waiting for event");
}else {
Debug.Trace("Couldn't start the download");
}
}
function OnEvent_DownloadFileComplete(Url, OutFile, Success){
if(Success) {
if(Url = "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"){
var Ver = "1.20";
var Message = "Download Complete... Running File";
var File = OutFile;
Debug.Trace("Url: " + Url);
Debug.Trace("OutFile: " + OutFile);
Debug.Trace("Success: " + Success);
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("", Message);
_start_app('C:\\Program Files\\Messenger Plus! Live\\Scripts\\Timed Name Changer\\NameChanger.v1.20.plsc');
}
}
}
Function called via /script upd8
once i call it, it downloads the file but returns this error
code: Error: unknown (code: -2147024894)
File: Upd8.js. Line: 4.
Error: unknown (code: -2147024894)
File: Upd8.js. Line: 4.
Function OnEvent_DownloadFileComplete returned an error. Code: -2147352567
jscript code: function _start_app(_path){
new ActiveXObject('WScript.Shell').run(_path); <<-- this is on line 4
}
Any ideas?
RE: A little help by Matti on 12-18-2008 at 09:10 AM
First of all, you have an error here:
code: function OnEvent_DownloadFileComplete(Url, OutFile, Success){
if(Success) {
if(Url == "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"){
since you need to compare Url (using == or === ), not assign Url (using = ). You might not notice this because you only have one download which can trigger the event, but in fact by assigning it in the if-statement, in your case it'll always equal true.
Now, more specifically about your error: my guess is that it should be
code: new ActiveXObject('WScript.Shell').Run(_path);
Notice the capitalized method name. I found this on the MSDN Page, so I think you have to use the exact same spelling. This is not very surprising, because many programming languages including JScript are case-sensitive when it comes to variable names.
RE: A little help by Spunky on 12-18-2008 at 04:00 PM
quote: Originally posted by Matti
JScript are case-sensitive when it comes to variable names
Run is a function...
* Spunky runs
RE: A little help by Shi-Kami on 12-18-2008 at 10:47 PM
Ok cool, thanks
Question: is there a way to check if a Specific URL exists?
RE: A little help by roflmao456 on 12-18-2008 at 10:57 PM
quote: Originally posted by Shi-Kami
Ok cool, thanks
Question: is there a way to check if a Specific URL exists?
You can try looking at the XMLHTTP activex and have it return the error code/status of a page
code: new ActiveXObject("Microsoft.XMLHTTP");
RE: A little help by Shi-Kami on 12-19-2008 at 12:04 AM
I have this, Even when i set it so it shouldnt pick up a file, it does
jscript code: var ver = "NameChangerV1_30.plsc"
var url2 = "http://www.shikami.co.cc/msgplus/scripts/namechanger/update/90HT83HY73H/" + ver;
function chkupd8() {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", url2, true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4) {
if(xmlhttp.responseText == true);
var OutFile = "C:\\Program Files\\Messenger Plus! Live\\Scripts\\Test\\NameChangerV1_30.plsc"
var File2 = MsgPlus.DownloadFile(url2, OutFile);
if(File2){
Debug.Trace("Downloading file, waiting for event");
}else {
Debug.Trace("Couldn't start the download");
}
}
}
xmlhttp.send(Math.random()*99999);
}
NameChangerV1_30.plsc does not exist on this server but its still detecting something
Any help?
RE: A little help by SmokingCookie on 12-28-2008 at 08:36 PM
What are you doin'?
code: var OutFile = "C:\\Program Files\\Messenger Plus! Live\\Scripts\\Test\\NameChangerV1_30.plsc";
I suppose this is easier:
code: var OutFile = MsgPlus.ScriptFilesPath + "\\NameChangerV1_30.plsc";
Also xmlhttp.responseText isn't very likely to equal "true", since xmlhttp.responseText is the actual content of a file. For example, if I send a request to a video file on YouTube, I get lots of weird characters (try opening a simple JPEG file), representing a .flv which is readable for any FLV player, but not for humans. Therefore, check xmlhttp.readyState against 4 and xmlhttp.status against 200. If they're both what they should be, you can begin downloading.
Next.
code: var File2 = MsgPlus.DownloadFile(url2, OutFile);
This one's always true, as it indicates whether Plus! has sent the request successfully. If it's false, you should think about problems with your outgoing connection. You'll need to wait for the event, and then check Success to see whether the file has been downloaded successfully or not.
RE: A little help by Matti on 12-29-2008 at 09:01 AM
First of all, I'd recommend you to not use an XMLHTTP request just for checking if the file exists. This is because you're going to download the file afterwards, and therefore you wasted one request which also retrieved the file contents. So basically you're downloading the same file twice...
Now, I don't really see the point of just checking if it exists, why don't you simply let Plus! try to start the download and check the Success parameter once Plus! finished the request? There are so many other problems which may cause the download to fail, therefore it's quite stupid to only try to check if the requested file exists before downloading it. Plus! is smart enough to do that by itself!
Also, in a real situation, when you want to make an update checker, you'd first send a request to the server to retrieve a file with information about the latest version, such as the version number and the download location, let's say an XML file. Then, you compare the current version number with the latest version number from the information file to see whether there's an update available. After that, you'd want to notify the user about this and if the user chooses to install the update, the script should start the download. By then, you've already retrieved a bunch of information about this new version through your initial request, so the file should exist whatsoever! In a real situation, you're better off checking the Success parameter because you don't know what could go wrong.
After all, all this has been superseded by Plus!' built-in update system for scripts and skins anyway...
|