Som besökare på Hamsterpaj samtycker du till användandet av s.k. cookies för att förbättra din upplevelse hos oss. Jag förstår, ta bort denna ruta!
Annons

Ändra i koden (msn script)?

Skapad av username, 2011-02-05 16:54 i Webbutveckling & Programmering

389
1 inlägg
0 poäng
username
Visningsbild
Luleå Hjälte 285 inlägg
0
Jag har MSN och skaffat för några dagar sedan ett script där jag kan ändra status med hjälp av 'snabbtangenter/hotkeys'. Så jag trycker på t.ex ALT+2 så ändras min status till upptagen.
När jag gör detta så kommer en popup som säger "New Status: Busy", som jag tycker är ganska störande..
Så jag provade tabort en del av funktionen i denna kod, men då verkar den helt plötsligt sluta fungera helt.

Här är hela koden

Visa spoiler
[code://////////////////////////////////////////////////////////////////////////// ///----------This Scipt was written by [S]punky[L]ove[M]uff--------------/// //////////////////////////////////////////////////////////////////////////// var mousePos = Interop.Allocate(8); var mouse = new Object(); var Wnd; var _subclass_handle; var WM_HOTKEY = 0x312; var showtoast = false; var navopen = false; var Wnd2; function OnEvent_Initialize(MessengerStart){ if(Messenger.MyStatus > 1){ OnEvent_SigninReady(Messenger.MyEmail); } } function OnWndStatusEvent_CtrlClicked(PlusWnd, ControlId){ switch(ControlId){ case "online": Messenger.MyStatus = 3; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Online")}; break; case "offline": Messenger.MyStatus = 2; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Appear Offline")}; break; case "busy": Messenger.MyStatus = 4; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Busy")}; break; case "away": Messenger.MyStatus = 7; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Away")}; break; case "brb": Messenger.MyStatus = 5; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Be Right Back")}; break; case "phone": Messenger.MyStatus = 8; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
On The Phone")}; break; case "lunch": Messenger.MyStatus = 9; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","New Status:
Out To Lunch")}; break; case "signout": Messenger.Signout; if(showtoast==true){MsgPlus.DisplayToast("StatusKey","Signing Out")}; break; } try{ PlusWnd.Close(1); }catch(e){} showtoast=false; } function getDecimal(key){ switch(key.toLowerCase()){ case "a": return 65; break; case "b": return 66; break; case "c": return 67; break; case "d": return 68; break; case "e": return 69; break; case "f": return 70; break; case "g": return 71; break; case "h": return 72; break; case "i": return 73; break; case "j": return 74; break; case "k": return 75; break; case "l": return 76; break; case "m": return 77; break; case "n": return 78; break; case "o": return 79; break; case "p": return 80; break; case "q": return 81; break; case "r": return 82; break; case "s": return 83; break; case "t": return 84; break; case "u": return 85; break; case "v": return 86; break; case "w": return 87; break; case "x": return 88; break; case "y": return 89; break; case "z": return 90; break; case "1": return 49; break; case "2": return 50; break; case "3": return 51; break; case "4": return 52; break; case "5": return 53; break; case "6": return 54; break; case "7": return 55; break; case "8": return 56; break; case "9": return 57; break; case "0": return 58; break; } } function OnEvent_SigninReady(Email){ try{ Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfe); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfd); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfc); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfb); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfa); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xef); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xee); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xed); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xec); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xeb); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xea); }catch(e){} _subclass_handle = MsgPlus.CreateWnd('Hotkey Subclass.xml', 'WndHotkeySubclass', 2); _subclass_handle.RegisterMessageNotification(WM_HOTKEY); try{ var mod = Read("mod")*1; var skey = getDecimal(Read("skey")); var key1 = getDecimal(Read("key1")); var key2 = getDecimal(Read("key2")); var key3 = getDecimal(Read("key3")); var key4 = getDecimal(Read("key4")); var key5 = getDecimal(Read("key5")); var key6 = getDecimal(Read("key6")); var key7 = getDecimal(Read("key7")); var key8 = getDecimal(Read("key8")); }catch(e){ var mod = 1; var skey = 83 var key1 = 49; var key2 = 50 var key3 = 51 var key4 = 52 var key5 = 53 var key6 = 54 var key7 = 55 var key8 = 56 } try{ var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xfe, mod, skey); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xfd, mod, key1); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xfc, mod, key2); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xfb, mod, key3); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xfa, mod, key4); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xef, mod, key5); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xee, mod, key6); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xed, mod, key7); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xec, mod, key8); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xeb, 8, skey); var lRet = Interop.Call('user32.dll', 'RegisterHotKey', _subclass_handle.Handle, 0xea, 12, skey); }catch(e){} } function OnEvent_Uninitalize(bMessengerExit){ try{ Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfe); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfd); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfc); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfb); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xfa); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xef); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xee); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xed); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xec); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xeb); Interop.Call('user32.dll', 'UnregisterHotKey', _subclass_handle.Handle, 0xea); }catch(e){} } function MakeWndTransparent(hWnd, lTransparencyLevel){ var nMsg = Interop.Allocate(4); var GWL_STYLE = (-20); var LWA_ALPHA = 0x2; var WS_EX_LAYERED = 0x80000; var WS_EX_TRANSPARENT = 0x20; nMsg.WriteDWORD(0, Interop.Call('user32', 'GetWindowLongW', hWnd, GWL_STYLE) | WS_EX_LAYERED); Interop.Call('user32', 'SetWindowLongW', hWnd, GWL_STYLE, nMsg.ReadDWORD(0)); Interop.Call('user32', 'SetLayeredWindowAttributes', hWnd, 0, lTransparencyLevel, LWA_ALPHA); } function OnEvent_ChatWndSendMessage(ChatWnd, Message){ if(Message.substr(0,7)=="/status"){try{Wnd.Close(1)}catch(e){}; ret = Interop.Call("user32.dll", "GetCursorPos", mousePos); if (ret != 0) { mouse.x = mousePos.ReadDWORD(0); mouse.y = mousePos.ReadDWORD(4); } Wnd = MsgPlus.CreateWnd("Windows.xml","WndStatus",1); with(Wnd){ Visible=false; Interop.Call("user32.dll","SetWindowPos",Wnd.Handle,-1,mouse.x-110,mouse.y-10,0,0,1); MakeWndTransparent(Wnd.Handle,220); } Wnd.Visible = true; return ""; } } function OnWndHotkeySubclassEvent_MessageNotification(pPlusWnd, nMessage, wParam, lParam){ if(wParam!=254){ showtoast=true } switch(wParam){ case 254: try{ Wnd.Close(1) }catch(e){ OnEvent_ChatWndSendMessage("", "/status") } break; case 253: OnWndStatusEvent_CtrlClicked("", "online") break; case 252: OnWndStatusEvent_CtrlClicked("", "offline") break; case 251: OnWndStatusEvent_CtrlClicked("", "busy") break; case 250: OnWndStatusEvent_CtrlClicked("", "away") break; case 239: OnWndStatusEvent_CtrlClicked("", "brb") break; case 238: OnWndStatusEvent_CtrlClicked("", "phone") break; case 237: OnWndStatusEvent_CtrlClicked("", "lunch") break; case 236: OnWndStatusEvent_CtrlClicked("", "signout") break; case 235: forward(); break; case 234: backward(); break; } } var q=-1; var StatusArr = new Array(); var StatusPic = new Array(); StatusArr[0] = "Online" StatusPic[0] = "online2.png" StatusArr[1] = "Offline" StatusPic[1] = "offline2.png" StatusArr[2] = "Busy" StatusPic[2] = "busy2.png" StatusArr[3] = "Away" StatusPic[3] = "away2.png" StatusArr[4] = "Be Right Back" StatusPic[4] = "away2.png" StatusArr[5] = "On The Phone" StatusPic[5] = "busy2.png" StatusArr[6] = "Out To Lunch" StatusPic[6] = "away2.png" var trans = 0; function AnimateWindow(pPlusWnd){ Interop.Call("User32", "AnimateWindow", pPlusWnd.Handle, 1000, 0x10000|0x80000); } function forward(){ MsgPlus.CancelTimer("close"); if(navopen!=true){ Wnd2=MsgPlus.CreateWnd("Windows.xml","WndNav");} navopen = true; q++; if(q==6){q=0}; try{ Wnd2.SetControlText("lbl_display",StatusArr[q]); Wnd2.ImageElmt_SetImageFile("picture",StatusPic[q]); }catch(e){ Wnd2=MsgPlus.CreateWnd("Windows.xml","WndNav"); Wnd2.SetControlText("lbl_display",StatusArr[q]); Wnd2.ImageElmt_SetImageFile("picture",StatusPic[q]); } MsgPlus.AddTimer("close",2000); } function backward(){ MsgPlus.CancelTimer("close"); if(navopen!=true){ Wnd2=MsgPlus.CreateWnd("Windows.xml","WndNav");} navopen = true; q--; if(q==-1){q=6}; try{ Wnd2.SetControlText("lbl_display",StatusArr[q]); Wnd2.ImageElmt_SetImageFile("picture",StatusPic[q]); }catch(e){ Wnd2=MsgPlus.CreateWnd("Windows.xml","WndNav"); Wnd2.SetControlText("lbl_display",StatusArr[q]); Wnd2.ImageElmt_SetImageFile("picture",StatusPic[q]); } MsgPlus.AddTimer("close",2000); } function OnEvent_Timer(timer){ if(timer=="close"){ if(q==0){Messenger.MyStatus=3} if(q==1){Messenger.MyStatus=2} if(q==2){Messenger.MyStatus=4} if(q==3){Messenger.MyStatus=7} if(q==4){Messenger.MyStatus=5} if(q==5){Messenger.MyStatus=8} if(q==6){Messenger.MyStatus=9} AnimateWindow(Wnd2); try{Wnd2.Close(1)}catch(e){}; navopen = false; } } function OnGetScriptCommands(){ var commands = '<ScriptCommands>'; commands+='<Command>'; commands+='<Name>statuskey</Name>'; commands+='<Description>Opens StatusKey window</Description>'; commands+='</Command>'; commands += '</script>'; return commands; } function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){ if(MenuItemId=="about"){ MsgPlus.CreateWnd("Windows.xml","WndAbout"); } if(MenuItemId=="config"){ var config = MsgPlus.CreateWnd("Windows.xml","WndConfig"); try{ config.SetControlText("txt_key1",Read("key1")); config.SetControlText("txt_key2",Read("key2")); config.SetControlText("txt_key3",Read("key3")); config.SetControlText("txt_key4",Read("key4")); config.SetControlText("txt_key5",Read("key5")); config.SetControlText("txt_key6",Read("key6")); config.SetControlText("txt_key7",Read("key7")); config.SetControlText("txt_key8",Read("key8")); config.SetControlText("txt_skey",Read("skey")); var mod = Read("mod"); }catch(e){ config.SetControlText("txt_key1","1"); config.SetControlText("txt_key2","2"); config.SetControlText("txt_key3","3"); config.SetControlText("txt_key4","4"); config.SetControlText("txt_key5","5"); config.SetControlText("txt_key6","6"); config.SetControlText("txt_key7","7"); config.SetControlText("txt_key8","8"); var mod=0; } if(mod==1){ config.Button_SetCheckState("chk_alt",true); } if(mod==2){ config.Button_SetCheckState("chk_ctrl",true); } if(mod==3){ config.Button_SetCheckState("chk_alt",true); config.Button_SetCheckState("chk_ctrl",true); } if(mod==4){ config.Button_SetCheckState("chk_shift",true); } if(mod==5){ config.Button_SetCheckState("chk_shift",true); config.Button_SetCheckState("chk_alt",true); } if(mod==6){ config.Button_SetCheckState("chk_ctrl",true); config.Button_SetCheckState("chk_shift",true); } if(mod==7){ config.Button_SetCheckState("chk_ctrl",true); config.Button_SetCheckState("chk_shift",true); config.Button_SetCheckState("chk_alt",true); } if(mod==8){ config.Button_SetCheckState("chk_win",true); } if(mod==9){ config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_alt",true); } if(mod==10){ config.Button_SetCheckState("chk_ctrl",true); config.Button_SetCheckState("chk_win",true); } if(mod==11){ config.Button_SetCheckState("chk_ctrl",true); config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_alt",true); } if(mod==12){ config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_shift",true); } if(mod==13){ config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_shift",true); config.Button_SetCheckState("chk_alt",true); } if(mod==14){ config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_shift",true); config.Button_SetCheckState("chk_ctrl",true); } if(mod==14){ config.Button_SetCheckState("chk_alt",true); config.Button_SetCheckState("chk_win",true); config.Button_SetCheckState("chk_shift",true); config.Button_SetCheckState("chk_ctrl",true); } } } function OnWndConfigEvent_CtrlClicked(PlusWnd, ControlId){ if(ControlId=="btn_ok"){ var valid=0; if(PlusWnd.GetControlText("txt_key1")!=""){ Write("key1",PlusWnd.GetControlText("txt_key1").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key2")!=""){ Write("key2",PlusWnd.GetControlText("txt_key2").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key3")!=""){ Write("key3",PlusWnd.GetControlText("txt_key3").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key4")!=""){ Write("key4",PlusWnd.GetControlText("txt_key4").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key5")!=""){ Write("key5",PlusWnd.GetControlText("txt_key5").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key6")!=""){ Write("key6",PlusWnd.GetControlText("txt_key6").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key7")!=""){ Write("key7",PlusWnd.GetControlText("txt_key7").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_key8")!=""){ Write("key8",PlusWnd.GetControlText("txt_key8").substr(0,1)); valid++; } if(PlusWnd.GetControlText("txt_skey")!=""){ Write("skey",PlusWnd.GetControlText("txt_skey").substr(0,1)); valid++; } var mod = 0; if(PlusWnd.Button_IsChecked("chk_alt")==true){ mod += 1; } if(PlusWnd.Button_IsChecked("chk_ctrl")==true){ mod += 2; } if(PlusWnd.Button_IsChecked("chk_shift")==true){ mod += 4; } if(PlusWnd.Button_IsChecked("chk_win")==true){ mod += 8; } if(mod!=0){ Write("mod",mod); var mvalid=true; }else{ var mvalid=false; } OnEvent_Uninitalize(); OnEvent_SigninReady(Messenger.MyEmail); if(valid==9&&mvalid==true){ PlusWnd.Close(1); }else if(valid!=9&&mvalid==true){ msgbox("StatusKey", (9-valid)+" boxes are left to fill in",16); }else if(valid==9&&mvalid==false){ msgbox("StatusKey", "At least one modifier key should be selected", 16); }else if(valid!=9&&mvalid==false){ msgbox("StatusKey", (9-valid)+" boxes are left to fill in
At least one modifier key should be selected", 16); } } } function msgbox(mTitle, mMessage,icon){ if(icon==undefined){ Interop.Call("User32.dll", "MessageBoxW", 0, mMessage, mTitle, 0); //MsgBox }else{ Interop.Call("User32.dll", "MessageBoxW", 0, mMessage, mTitle, icon); //MsgBox } } function OnWndAboutEvent_CtrlClicked(PlusWnd, ControlId){ if(ControlId=="btn_ok"){ PlusWnd.Close(1); } } function OnGetScriptMenu(nLocation){ var ScriptMenu = "<ScriptMenu>"; ScriptMenu += "<MenuEntry Id="config">Configuration</MenuEntry>"; ScriptMenu += "<Separator/>"; ScriptMenu += "<MenuEntry Id="about">About</MenuEntry>"; ScriptMenu += "</script>"; return ScriptMenu; } function Write(key, value){ return new ActiveXObject("WScript.Shell").RegWrite(MsgPlus.ScriptRegPath + Messenger.MyUserID + "" + key, value, "REG_SZ"); } function Read(key){ return new ActiveXObject("WScript.Shell").RegRead(MsgPlus.ScriptRegPath + Messenger.MyUserID + "" + key); }][/code]


Ibörjan står det om det där "New Status", så jag tog bort den raden, från "function OnWndStatusEvent_CtrlClicked(PlusWnd, ControlId){" till end brackets }, som ligger just innan "function getDecimal(key){".

Men när jag gjorde det, slutade allt att fungera.
Någon som vet hur jag editerar den rätt?
Här är f.ö skriptet, om det är svårt att läsa texten ovan då den blev konstig när jag klistrade in:
http://www.msgplus.net/scripts/view/164-StatusKey/

Tillägg av username 2011-02-05 16:56

http://data.fuskbugg.se/skalman02/Statuskey2.txt
Där är det nog lättare att läsa av koden.

Är reklamen ivägen? Logga in eller registrera dig så försvinner den!


Forum » Datorer & IT » Webbutveckling & Programmering » Ändra i koden (msn script)?

Ansvariga ordningsvakter:

Användare som läser i den här tråden just nu

1 utloggad

Skriv ett nytt inlägg

Hej! Innan du skriver om ett potentiellt problem så vill vi påminna dig om att du faktiskt inte är ensam. Du är inte onormal och världen kommer inte att gå under, vi lovar! Så slappna av och gilla livet i några minuter - känns det fortfarande hemskt? Skriv gärna ner dina tankar och frågor, vi älskar att hjälpa just dig!

Den här tråden är äldre än Rojks drömtjej!

Det senaste inlägget i den här tråden skrevs för över tre månader sedan. Är du säker på att du vill återuppliva diskussionen? Har du något vettigt att tillföra eller passar din fråga i en ny tråd? Onödiga återupplivningar kommer att låsas så tänk efter en extra gång!

Hjälp

Det här är en hjälpruta

Här får du korta tips och förklaringar om forumet. Välj kapitel i rullningslisten här ovanför.

Rutan uppdateras automagiskt

När du använder funktioner i forumet så visas bra tips här.


Annons
Annons
Annons
Annons