Script

Forum rules
Need help with something? Anything? Post here.

Post a reply

Smilies
:smooch: :kitty: :hickrock: :music: :rake: :bash: :buba: :funnyshit: :welcome: :cyclops: :dance: :deal: :pclove: :gamer: :penguin: :fly: :ninja: :artist: :beer: :rocker: :spongebob: :link: :hunter: :psmurf: :hitler: :smurf: :geek: :loco: :music: :nosepicker: :ph34r: :pilot: :popcorn: :rtfm: :roulette: :sarcastic: :scenic: :suicide: :sun: :tele: :wacko: :wizard: :aggressive: :airkiss: :dance: :dash: :diablo: :unclesam: :fu: :gamer: tp(( ppr( aa) bbn) ac) :roll: 1234(( ii998) tt556) 3322)) 4455() :D :) :( :o :shock: :? 8-) hh) :mad: :oops: ;) :evil: :twisted: :!: :?: ab) :arrow: :idea:
View more smilies

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Script

Re: Script

by fl00d3d » January 31st, 2008, 12:05 am

raulperez wrote:i was under the impression Javascript was a JAVA based language with nothing to do with C, aside from a few ideas from C++?
Java is also C-based. Many languages are ;)

Re: Script

by raulperez » January 30th, 2008, 11:37 pm

i was under the impression Javascript was a JAVA based language with nothing to do with C, aside from a few ideas from C++?

in other news, why do you even need that script?

Re: Script

by ratty » January 30th, 2008, 7:20 pm

soooooo no help...... =(

Re: Script

by fl00d3d » January 24th, 2008, 2:54 pm

Regardless, Javascript and C# are both C-based languages. Point is: its not a mIRC script ;)

Re: Script

by Starlite » January 24th, 2008, 1:55 pm

Isn't MSN scripting JavaScript? ;x

Re: Script

by danpaul88 » January 24th, 2008, 1:03 pm

It probably is .NET based like C# then, since .NET is Microsoft stuff.

Re: Script

by ratty » January 24th, 2008, 1:01 pm

msn script =D

Re: Script

by danpaul88 » January 24th, 2008, 12:36 pm

It looks like C# code to me, but I can't be sure, only had a quick look through it

Re: Script

by Starlite » January 24th, 2008, 10:03 am

This is meant to be an IRC Script?

If so, LOL

Re: Script

by Commie » January 23rd, 2008, 11:11 pm

Jesus that's big :shock:

Script

by ratty » January 23rd, 2008, 11:10 pm

I felt this is probably best one to post in. The part of the scrip that doesnt work is when it displays processor stuff =D the rest is fine. ( ratty says: CPU Speed : NaN GHZ )

Spoiler: show
function OnEvent_Initialize(bMessengerStart){
details = new ActiveXObject("WbemScripting.SWbemLocator");
serv = details.ConnectServer();
}


function wmi(name,wrapAlways){
var x = serv.ExecQuery('select * from ' + name);

var items = []
for(var enume = new Enumerator(x);!enume.atEnd();enume.moveNext()){
items[items.length] = enume.item()
}


if(items.length == 1){
if(typeof(wrapAlways) != 'undefined'){
return items;
}else{
return items[0];
}
}else
return items;
}


function OnEvent_MenuClicked(sMenuId, location, wnd){

switch(sMenuId){
case 'OS_name' : wnd.SendMessage('OS: ' + OStitle());return;

case 'Mem_load' : wnd.SendMessage('Memory Load: ' + getRam('percent') + '%');return;
case 'Mem_amount' : wnd.SendMessage('Memory Used: ' + getRam('totals'));return;
case 'Mem_summary' : wnd.SendMessage('Memory: ' + getRam('summary'));return;
case 'Mem_page' : wnd.SendMessage('Page File: ' + getPageFile());return;

case "HDD_total" : wnd.SendMessage('HDD: ' + HDDspace('total'));return;
case "HDD_all" : wnd.SendMessage('HDD: ' + HDDspace('summary'));return;

case "Proc_name" : wnd.SendMessage('/noicon CPU Name: ' + getProcessor('name'));return;
case "Proc_clock" : wnd.SendMessage('CPU Speed: ' + getProcessor('clock')+ ' GHZ') ;return;
case "Proc_load" : wnd.SendMessage('CPU Load: ' + getProcessor('load') + '%');return;
case "Proc_summary" : wnd.SendMessage('/noicon CPU: ' + getProcessor('summary') );return;

case "Video_name" : wnd.SendMessage('GFX Name: ' + getGraphicCard('name') );return;
case "Video_memory" : wnd.SendMessage('GFX memory: ' + getGraphicCard('memory') + 'MB' );return;
case "Video_resolution" : wnd.SendMessage('Resolution: ' + getGraphicCard('resolution') + ' (' +getGraphicCard('refresh') + 'HZ)' );return;
case "Video_summary" : wnd.SendMessage('GFX: ' + getGraphicCard('summary') );return;


case "Online" : wnd.SendMessage('Contacts Online: ' + getContacts('summary') );return;
case "Blocked" : wnd.SendMessage('Contacts Blocked: ' + getContacts('blocked') );return;
case "Uptime" : wnd.SendMessage('Uptime: ' + getUptime()); return;

}

var name;
if(name = sMenuId.match(/Soundcard_(.*)$/)){
wnd.SendMessage('SoundCard : ' + name[1]);
return;

}else if(name = sMenuId.match(/net_([^_]*)_(.*)$/)){
if(name[2] == 'name'){
wnd.SendMessage('Connection Name: ' + name[1]);
}else{
wnd.SendMessage('Connection '+name[2]+': ' + getConnectionInfo(name[1],name[2]));
}
}
}


//TAGS


function OnEvent_ChatWndSendMessage(chatWnd,message){
//seems it will run the function even if it doesnt match... so we test for a match before the replace


if(message.match(/\(!OS\)/ig))message = message.replace(/\(!OS\)/ig, OStitle());

if(message.match(/\(!MEMLOAD\)/ig))message = message.replace(/\(!MEMLOAD\)/ig, getRam('percent'));
if(message.match(/\(!MEMTOTAL\)/ig))message = message.replace(/\(!MEMTOTAL\)/ig, getRam('totals'));
if(message.match(/\(!MEMSUMMARY\)/ig))message = message.replace(/\(!MEMSUMMARY\)/ig, getRam('summary'));

if(message.match(/\(!HDDTOTAL\)/ig))message = message.replace(/\(!HDDTOTAL\)/ig, HDDspace('total'));
if(message.match(/\(!HDDSUMMARY\)/ig))message = message.replace(/\(!HDDSUMMARY\)/ig, HDDspace('summary'));

if(message.match(/\(!CPUNAME\)/ig))message = message.replace(/\(!CPUNAME\)/ig,getProcessor('name'));
if(message.match(/\(!CPUCLOCK\)/ig))message = message.replace(/\(!CPUCLOCK\)/ig,getProcessor('clock'));
if(message.match(/\(!CPULOAD\)/ig))message = message.replace(/\(!CPULOAD\)/ig,getProcessor('load'));
if(message.match(/\(!CPUSUMMARY\)/ig))message = message.replace(/\(!CPUSUMMARY\)/ig,getProcessor('summary'));

if(message.match(/\(!GFXNAME\)/ig))message = message.replace(/\(!GFXNAME\)/ig, getGraphicCard('name')+'MB');
if(message.match(/\(!GFXMEMORY\)/ig))message = message.replace(/\(!GFXMEMORY\)/ig, getGraphicCard('memory'));
if(message.match(/\(!GFXRES\)/ig))message = message.replace(/\(!GFXRES\)/ig, getGraphicCard('resolution'));
if(message.match(/\(!GFXREFRESH\)/ig))message = message.replace(/\(!GFXREFRESH\)/ig, getGraphicCard('refresh') + 'HZ');
if(message.match(/\(!GFXSUMMARY\)/ig))message = message.replace(/\(!GFXSUMMARY\)/ig, getGraphicCard('summary'));

if(message.match(/\(!CONTACTSBLOCKED\)/ig))message = message.replace(/\(!CONTACTSBLOCKED\)/ig,getContacts('blocked'));
if(message.match(/\(!CONTACTSONLINE\)/ig))message = message.replace(/\(!CONTACTSONLINE\)/ig,getContacts('summary'));


if(message.match(/\(!UPTIME\)/ig))message = message.replace(/\(!UPTIME\)/ig,getUptime());

return message;
}



//getContacts function idea by lou_habs :P
function getContacts(type){

var contacts = Messenger.MyContacts;

var online = 0;
var offline = 0;
var total = 0;
var blocked = 0;
var c;
for(var enume = new Enumerator(contacts);!enume.atEnd();enume.moveNext()){
total++;
c = enume.item();
if(c.Status != 1){
online++;
}else{
offline++;
}

if(c.Blocked)blocked++;


}



var percent = Math.round((online / total) *100);

switch(type){
case 'summary' : return online + '/' + total + ' (' + percent + '%)';
case 'blocked' : return blocked;

}

}




function getUptime(){
var uptime = wmi('Win32_OperatingSystem').LastBootUpTime;

var start = dateTimetoRealTime(uptime).getTime();
var now = new Date().getTime();
var secs = Math.round((now - start) / 1000);

var st = '';
var days = removeDec(secs / 86400);

if(days >= 1){

if(days == 1){
st += days + ' day ';
}else{
st += days + ' days ';
}

secs = secs - (days * 86400);
}

var hours = removeDec(secs / 3600);

if(hours >= 1){
if(hours == 1){
st += hours + ' hour ';
}else{
st += hours-1 + ' hours ';
}

secs = secs - (hours * 3600)
}

var mins = removeDec(secs / 60);

if(mins >= 1){
if(mins == 1){
st += mins + ' minute ';
}else{
st += mins + ' minutes ';
}

secs = secs - (mins * 60);
}

st += 'and ' + secs + ' seconds'

return st;
}

function removeDec(num){
return String(num).split('.')[0];
}


function dateTimetoRealTime(date){
//2006 06 04 14 15 53.500000+570
dates = String(date);
var year = parseInt(dates.substr(0,4));
var month = parseInt(dates.substr(4,2))-1;
var day = parseInt(dates.substr(6,2));

var hour = parseInt(dates.substr(8,2))-1;
var min = parseInt(dates.substr(10,2))-1;
var sec = parseInt(dates.substr(12,2))-1;

return new Date(year,month,day,hour,min,sec);
}


function getConnectionInfo(name ,type){
//find the right card.
var connections = wmi('Win32_PerfRawData_Tcpip_NetworkInterface');

for(var i=0;i<connections.length;i++){
if(connections.Name == name){

switch(type){
case 'MB Received' : return Math.round((connections.BytesReceivedPersec /1024 /1024)*100)/100 + 'MB';
case 'MB Sent' : return Math.round((connections.BytesSentPersec /1024 /1024)*100)/100 + 'MB';
case 'summary' : return connections.Name + ' , Sent: ' + Math.round((connections.BytesSentPersec /1024 /1024)*100)/100 + 'MB Received: ' + Math.round((connections.BytesReceivedPersec /1024 /1024)*100)/100 + 'MB'
}



}
}


return 'unknown';

}




function getGraphicCard(type){
var gfx = wmi('Win32_VideoController');

switch(type){
case "name" : return gfx.Name;
case "memory" : return gfx.AdapterRAM / 1024 / 1024;
case "resolution" : return gfx.CurrentHorizontalResolution + 'x' + gfx.CurrentVerticalResolution;
case "refresh" : return gfx.CurrentRefreshRate;
case "summary" : return gfx.Name +' ' + gfx.AdapterRAM / 1024 / 1024 + 'MB @ ' + gfx.CurrentHorizontalResolution + 'x' + gfx.CurrentVerticalResolution + " (" + gfx.CurrentRefreshRate +"HZ)";
}

}



function getProcessor(type){
var proc = wmi('Win32_Processor');
if(typeof(proc)=='array')proc=proc[0];
switch(type){
case "name" : return stripWhiteSpace(proc.Name);
case "clock" : return Math.round((proc.CurrentClockSpeed /1000)*100)/100;
case "load" : return proc.LoadPercentage;
case "summary" : return stripWhiteSpace(proc.Name) + ', ' + Math.round((proc.CurrentClockSpeed /1000)*100)/100 + 'GHZ (' +proc.LoadPercentage +'% Load)';
}
}

function stripWhiteSpace(str){
str = str.replace(/^([ ]*)/,'');
str = str.replace(/([ ]*)$/,'');
return str;
}


function roundToTwoPoints(num){
var st = String(num);

if(st.match('.')){
var parts = st.split('.');
parts[1] = parts[1].substr(0,1);
return parts.join('.') + 0;
}else{
return num + 0;
}

}


function HDDspace(type){
var devices = wmi('Win32_LogicalDisk');

var freeSpace = 0;
var totalSpace = 0;

var fs;
var ts;
var used;
var string = '';

for(var i=0;i<devices.length;i++){
if(devices.DriveType == 3){

ts = devices.Size / 1024 / 1024 /1024;
fs = ts - (devices.FreeSpace /1024 /1024 /1024);

string += '[' + devices.Caption + ']: ' + Math.round(fs * 100)/100 + 'GB/' + Math.round(ts *100)/100 + 'GB ';

freeSpace += fs
totalSpace += ts
}
}

switch(type){
case 'total' : return Math.round(freeSpace) + 'GB/' + Math.round(totalSpace) + 'GB';
case 'summary' : return string;

}

}


function OStitle(){
var os = wmi('Win32_OperatingSystem');
return os.Caption + ' - ' + os.CSDVersion + ' - ' + os.Version;
}


function getRam(type){
var rawused = wmi('Win32_PerfRawData_PerfOS_Memory').AvailableBytes / 1024 / 1024
var max = Math.round(wmi('Win32_LogicalMemoryConfiguration').TotalPhysicalMemory / 1024);
var used = Math.round(max - rawused);
var percent = Math.round(used / max *100)

switch(type){
case 'percent' : return percent;
case 'totals' : return used + '/' + max + ' MB';
case 'summary' : return used + '/' + max + ' MB ' + ' (load: ' + percent + '%)';
}

}

function getPageFile(){
var mem = wmi('Win32_LogicalMemoryConfiguration');
var totalPage = Math.round(mem.TotalPageFileSpace / 1024);
var av = Math.round(mem.AvailableVirtualMemory / 1024);
var used = totalPage - av;

Debug.Trace(page);



}


function OnGetScriptMenu(nLocation){



var sMenuInfo = "<ScriptMenu>"
if(nLocation == 2){

sMenuInfo += '<SubMenu Label="OS">';
sMenuInfo += '<MenuEntry Id="OS_name">Name</MenuEntry>';
sMenuInfo += '</SubMenu>';

sMenuInfo += '<SubMenu Label="Memory">';

sMenuInfo += '<MenuEntry Id="Mem_load">Load</MenuEntry>';
sMenuInfo += '<MenuEntry Id="Mem_amount">Amount</MenuEntry>';
sMenuInfo += '<Separator/>';
sMenuInfo += '<MenuEntry Id="Mem_summary">Summary</MenuEntry>';
sMenuInfo += '</SubMenu>';

sMenuInfo += '<SubMenu Label="Hard Drive">';
sMenuInfo += '<MenuEntry Id="HDD_total">Total</MenuEntry>';
sMenuInfo += '<MenuEntry Id="HDD_all">Summary</MenuEntry>';
sMenuInfo += '</SubMenu>';

sMenuInfo += '<SubMenu Label="Processor">';

sMenuInfo += '<MenuEntry Id="Proc_name">Name</MenuEntry>';
sMenuInfo += '<MenuEntry Id="Proc_clock">Clock</MenuEntry>';
sMenuInfo += '<MenuEntry Id="Proc_load">Load</MenuEntry>';
sMenuInfo += '<Separator/>';
sMenuInfo += '<MenuEntry Id="Proc_summary">Summary</MenuEntry>';
sMenuInfo += '</SubMenu>';

sMenuInfo += '<SubMenu Label="Video Card">';
sMenuInfo += '<MenuEntry Id="Video_name">Name</MenuEntry>';
sMenuInfo += '<MenuEntry Id="Video_memory">Memory</MenuEntry>';
sMenuInfo += '<Separator/>';
sMenuInfo += '<MenuEntry Id="Video_resolution">Resolution</MenuEntry>';
sMenuInfo += '<Separator/>';
sMenuInfo += '<MenuEntry Id="Video_summary">Summary</MenuEntry>';
sMenuInfo += '</SubMenu>';







sMenuInfo += '<SubMenu Label="Connections">';
var connections = wmi('Win32_PerfRawData_Tcpip_NetworkInterface');

for(var i=0;i<connections.length;i++){
sMenuInfo += '<SubMenu Label="'+ connections[i].Name +'" >';
sMenuInfo += '<MenuEntry Id="net_' +connections[i].Name +'_name">Name</MenuEntry>';
sMenuInfo += '<MenuEntry Id="net_' +connections[i].Name +'_MB Sent">MB sent</MenuEntry>';
sMenuInfo += '<MenuEntry Id="net_' +connections[i].Name +'_MB Received">MB Received</MenuEntry>';
sMenuInfo += '<Separator/>';
sMenuInfo += '<MenuEntry Id="net_' +connections[i].Name +'_summary">Summary</MenuEntry>';
sMenuInfo += '</SubMenu>';
}

sMenuInfo += '</SubMenu>';

sMenuInfo += '<SubMenu Label="Sound Card">';
var soundcards = wmi('Win32_SoundDevice',true);


for(var i=0;i<soundcards.length;i++){
sMenuInfo += '<MenuEntry Id="Soundcard_' +soundcards[i].Name +'">' + soundcards[i].Name +'</MenuEntry>';
}

sMenuInfo += '</SubMenu>';



sMenuInfo += '<SubMenu Label="Contacts">';
sMenuInfo += '<MenuEntry Id="Online">Online</MenuEntry>';
sMenuInfo += '<MenuEntry Id="Blocked">Blocked</MenuEntry>';
sMenuInfo += '</SubMenu>';

sMenuInfo += '<MenuEntry Id="Uptime">Uptime</MenuEntry>';

}
sMenuInfo += "</ScriptMenu>";
return sMenuInfo;

}

Top