Messenger Plus! Live - Forum italiano

Versione completa: Ecco come creare un semplice script per news
Al momento stai visualizzando i contenuti in una versione ridotta. Visualizza la versione completa e formattata.
In questo post insegnerò come creare un semplice script per avvisare quando il tuo sito è aggiornato:
Codice:
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
var Shell = new ActiveXObject("WScript.Shell");
var getal = Math.round(Math.random() * 99999) + 1;
function OnEvent_Initialize(MessengerStart) {
    xhr.open("GET", "www.miosito.it/pagina.php?id="+getal, false); xhr.send(null);
    if(xhr.responseText=="1"){
        MsgPlus.DisplayToast("News", "www.miosito.it aggiornato", "", aprisito);
    }    
    
}
function aprisito() {
    Shell.Run("www.miosito.it");
}

Allora,dove c'è http://www.miosito.it mettete il vostro sitoo(in tutti e due)
quindi se il mio sito è : http://www.ilblogtecnologico.jimdo.com sarà:
Codice:
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
var Shell = new ActiveXObject("WScript.Shell");
var getal = Math.round(Math.random() * 99999) + 1;
function OnEvent_Initialize(MessengerStart) {
  xhr.open("GET", "http://www.ilblogtecnologico.jimdo.com/pagina.php?id="+getal, false); xhr.send(null);
    if(xhr.responseText=="1"){
        MsgPlus.DisplayToast("News", "www.ilblogtecnologico.jimdo.com aggiornato ", "", aprisito);
    }
    
    
}
function aprisito() {
    Shell.Run("http://www.ilblogtecnologico.jimdo.com");
}

Dove c'è :
Codice:
if(xhr.responseText=="1"){
Al posto di "1" potete mettere 2 o 3 o 4.... Ma a cosa serve?

Allora:dove c'è
Codice:
xhr.open("GET", "http://www.ilblogtecnologico.jimdo.com/pagina.php?
ovviamente modificate il sito(http:// ci deve essere!) poi dove c'è pagina.php lo lasciate!! Adesso dobbiamo creare un pagina (pagina.php)
{consiglio:usate altervista.....}
ci scriviamo "1" o il numero che ci avete messo sopra..

Ritornando al codice dove c'è :
Codice:
"www.ilblogtecnologico.jimdo.com aggiornato ", "", aprisito);

modifichiamo il messaggio a piacere che poi verrà fuori come msgtoast.
Lo script in questo caso si avvia :
Codice:
function OnEvent_Initialize(MessengerStart) {
.

dopo bè...salvate lo script...fatto! ora se riavviate msn vedrete che verrà fuori il messaggio toast..ma se modificate "pagina.php" mettendo 0 o un numero che non avete inserito non verrà fuori!:-D Se avete dei problemi o non avete capito o volete più info:riki_1997@hotmail.it
In pratica ha le stesse funzioni dello script creato da suxsem....giusto?
no! Mia ha aiutato webbolo
:-| non ti avevo chiesto con chi l'hai fatto :)
Ti avevo chiesto se aveva le stesse funzioni di uno script che era stato creato in precedenza da suxsem :)
Vabbè, quando poi ho tempo verifico il codice...
Ho guardato adesso...hanno le stesse funzioni :)
function OnEvent_Signin()
{
ult=""
var Shell = new ActiveXObject("WScript.Shell");
url = Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\url");
tempo = Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\tempo");
ultimo = Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\ultimo");
filtro = Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\filtro");
attDis = Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\attDis");
if(ultimo=="-1"){
ultimo = true
}
if(ultimo=="0"){
ultimo = false
}
Agg()
ult=postDesc
if(ultimo==true){
MsgPlus.DisplayToast(NOME,"----------------------")
MsgPlus.DisplayToast(NOME,"di:\n"+di,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,postTitle,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,"Nuovo messaggio:\n\n"+ora,"","OnSomethingHappenedClick", 42)
}
MsgPlus.AddTimer("agg",tempo);
}

function OnEvent_Initialize(MessengerStart)
{
var objfile=new ActiveXObject("Scripting.FileSystemObject");
var pathfile=objfile.OpenTextFile(MsgPlus.ScriptFilesPath+"\\inf.txt" ,1);
NOME=pathfile.ReadLine()
INDRSS=pathfile.ReadLine()
SALTDISC=Number(pathfile.ReadLine())
VECCHIOS=pathfile.ReadLine()
if(MessengerStart==false){
//rimuovi vecchia versione
var fileSys = new ActiveXObject("Scripting.FileSystemObject");
if(fileSys.FileExists(MsgPlus.ScriptFilesPath.replace(/\\/g,"\\\\").substring(0,MsgPlus.ScriptFilesPath.replace(/\\/g,"\\\\").length-NOME.length)+VECCHIOS+"\\\\ScriptInfo.xml")==true){
fileSys.DeleteFolder(MsgPlus.ScriptFilesPath.replace(/\\/g,"\\\\").substring(0,MsgPlus.ScriptFilesPath.replace(/\\/g,"\\\\").length-NOME.length)+VECCHIOS,true);
var RegistryPath = (MsgPlus.ScriptRegPath.substring(0,MsgPlus.ScriptRegPath.length-(NOME.length+10))+VECCHIOS).substr(5); //Remove "HKCU\" prefix
var HKEY_CURRENT_USER = 0x80000001;
Registry_DeleteTree(HKEY_CURRENT_USER, RegistryPath);
Interop.Call("User32.dll", "MessageBoxW", 0, "E' necessario chiudere messenger, premere OK per proseguire",NOME, 0);
new ActiveXObject("WScript.Shell").Run("\""+MsgPlus.ScriptFilesPath.replace(/\\/g,"\\\\")+"\\close_msg.exe\"")
}
raccDi = new Array
raccCosa = new Array
raccOra = new Array
raccLink = new Array
url = INDRSS
tempo = 30000
ultimo = false
filtro = ""
attDis = "true"
var Shell = new ActiveXObject("WScript.Shell");
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\url", url);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\tempo", tempo);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\ultimo", ultimo);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\filtro", filtro);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\attDis", attDis);
Agg()
ult=postDesc
MsgPlus.AddTimer("agg",tempo);
MsgPlus.DisplayToast(NOME,"Impostazioni resettate")
}
}

function Registry_DeleteTree(lKeyLocation, sKey){
return Interop.Call('shlwapi.dll', 'SHDeleteKeyW', lKeyLocation, sKey) === 0;
}

function OnEvent_Timer(sTimerId){
if(sTimerId=="agg"){
MsgPlus.AddTimer("agg",tempo);
Ver()
if(attDis=="true"){
if(filtro!=di){
if(nuovo==true){
MsgPlus.DisplayToast(NOME,"----------------------")
MsgPlus.DisplayToast(NOME,"di:\n"+di,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,postTitle,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,"Nuovo messaggio:\n\n"+ora,"","OnSomethingHappenedClick", 42)
}
}
}
}
}

function OnSomethingHappenedClick()
{
var Shell = new ActiveXObject("WScript.Shell");
Shell.run(postLink);
}

function Agg(){
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
if(xmlDoc.load(url)==false){
MsgPlus.DisplayToast(NOME,"Errore durante l'aggiornamento dei feed RSS. Riprovare o controllare l'url inserito")
}
elePosts = xmlDoc.getElementsByTagName("item");
var readLink = elePosts[SALTDISC].getElementsByTagName("link");
postLink = readLink[0].firstChild.nodeValue;
var readTitle = elePosts[SALTDISC].getElementsByTagName("title");
postTitle = readTitle[0].firstChild.nodeValue;
var readDesc = elePosts[SALTDISC].getElementsByTagName("description");
postDesc = readDesc[0].firstChild.nodeValue;
di = postDesc.indexOf("blank")
di = postDesc.substring(di+7,postDesc.length-4)
ora = postDesc.substring(0,postDesc.indexOf(",")+10)
}

function Ver(){
Agg()
if(ult==postDesc){
nuovo = false
}else{
ult=postDesc
nuovo = true
raccDi[raccDi.length] = di
raccCosa[raccCosa.length] = postTitle
raccOra[raccOra.length] = ora
raccLink[raccLink.length] = postLink
try{
if(vt.Visible == true){
vt.Close(1)
apriVT()
}
}catch(e){
}
}
}

function OnGetScriptMenu(nLocation){
var ScriptMenu = "<scriptMenu>\n";
ScriptMenu += "Aggiorna";
ScriptMenu += "Visualizza ultimo";
ScriptMenu += "";
ScriptMenu += "Visualizza tutti";
ScriptMenu += "";
if(attDis=="true"){
ScriptMenu += "Disattiva script";
}
if(attDis=="false"){
ScriptMenu += "Attiva script";
}
ScriptMenu += "Configurazione";
ScriptMenu += "by Suxsem - v" + VERSIONE + " ScriptMenu += "</scriptMenu>";
return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId=="AG"){
Ver()
if(nuovo==false){
MsgPlus.DisplayToast(NOME,"Nessun nuovo messaggio")
}else{
if(filtro!=di){
MsgPlus.DisplayToast(NOME,"----------------------")
MsgPlus.DisplayToast(NOME,"di:\n"+di,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,postTitle,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,"Nuovo messaggio:\n\n"+ora,"","OnSomethingHappenedClick", 42)
}else{
MsgPlus.DisplayToast(NOME,"Nessun nuovo messaggio")
}
}
}
if(MenuItemId=="VU"){
Ver()
MsgPlus.DisplayToast(NOME,"----------------------")
MsgPlus.DisplayToast(NOME,"di:\n"+di,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,postTitle,"","OnSomethingHappenedClick", 42)
MsgPlus.DisplayToast(NOME,"Nuovo messaggio:\n\n"+ora,"","OnSomethingHappenedClick", 42)
}
if(MenuItemId=="VT"){
apriVT()
}
if(MenuItemId=="IM"){
im=MsgPlus.CreateWnd("windows.xml","configurazione")
if(url==INDRSS){
im.Button_SetCheckState("sorgenteRadio1",true)
im.Button_SetCheckState("sorgenteRadio2",false)
im.SetControlText("sorgenteText","Inserire indirizzo feed RSS")
}else{
im.Button_SetCheckState("sorgenteRadio2",true)
im.Button_SetCheckState("sorgenteRadio1",false)
im.SetControlText("sorgenteText",url)
}
im.SetControlText("tempoText",tempo/1000)
im.SetControlText("filtroText",filtro)
im.Button_SetCheckState("ultimoCB",ultimo)
}
if(MenuItemId=="DI"){
attDis = "false"
var Shell = new ActiveXObject("WScript.Shell");
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\attDis", attDis);
MsgPlus.DisplayToast(NOME,"Script disattivato")
}
if(MenuItemId=="AT"){
attDis = "true"
var Shell = new ActiveXObject("WScript.Shell");
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\attDis", attDis);
MsgPlus.DisplayToast(NOME,"Script attivato")
}
if(MenuItemId=="CO"){
co=MsgPlus.CreateWnd("windows.xml","informazioni")
}
}

function apriVT(){
vt=MsgPlus.CreateWnd("windows.xml","ultimi")
for(a=0;a var item =vt.LstView_AddItem("lstDisplay", a);
vt.LstView_SetItemText("lstDisplay", item, 0, raccOra[a]);
vt.LstView_SetItemText("lstDisplay", item, 1, raccDi[a]);
vt.LstView_SetItemText("lstDisplay", item, 2, raccCosa[a]);
vt.LstView_SetItemText("lstDisplay", item, 3, raccLink[a]);
vt.SendControlMessage("lstDisplay", /* LVM_ENSUREVISIBLE */ 0x1013, a, false)
}
}

function OninformazioniEvent_CtrlClicked(PlusWnd, ControlId){
if(ControlId=="exit"){
PlusWnd.Close(1)
}
}
function OnultimiEvent_CtrlClicked(PlusWnd, ControlId){
if(ControlId=="chiudiUltimi"){
vt.Close(1)
}
if(ControlId=="chiudiUltimi"){
vt.Close(1)
}
if(ControlId=="aggSep"){
raccDi[raccDi.length] = "-"
raccCosa[raccCosa.length] = "-"
raccOra[raccOra.length] = "-"
raccLink[raccLink.length] = "-"
vt.Close(1)
apriVT()
}
}

function OnultimiEvent_LstViewDblClicked(PlusWnd,ControlId,ItemIdx){
linkTemp = vt.LstView_GetItemText("lstDisplay", ItemIdx, 3)
var Shell = new ActiveXObject("WScript.Shell");
Shell.run(linkTemp);
}

function OnconfigurazioneEvent_CtrlClicked(PlusWnd, ControlId){
if(ControlId=="conferma"){
filtro=im.GetControlText("filtroText")
tempo=im.GetControlText("tempoText")
tempo=tempo.replace(/,/g,".")
tempo=Number(tempo)
if(String(tempo)=="NaN"){
Interop.Call("User32.dll", "MessageBoxW", 0, "Nel campo | Aggiorna ogni: | è possibile inserire solo un valore numerico",NOME, 0);
}else{
tempo=tempo*1000
if(im.Button_IsChecked("sorgenteRadio1")==true){
url = INDRSS
}
if(im.Button_IsChecked("sorgenteRadio2")==true){
url = im.GetControlText("sorgenteText")
}
if(im.Button_IsChecked("ultimoCB")==true){
ultimo = true
}else{
ultimo = false
}
var Shell = new ActiveXObject("WScript.Shell");
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\ultimo", ultimo);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\url", url);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\tempo", tempo);
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\filtro", filtro);
im.Close(1)
MsgPlus.DisplayToast(NOME,"Impostazioni salvate")
Agg()
ult=postDesc
}
}
if(ControlId=="notaBene"){
Interop.Call("User32.dll", "MessageBoxW", 0, "Nei circuiti forumfree e forumcommunity non è possibile ricevere feed RSS per messaggi scritti nelle sezioni protette con password o con restrizioni di accesso",NOME, 0);
}
}

function OnEvent_Uninitialize(MessengerExit)
{
}
URL di riferimento