Topic started by Reines 18-06-2008 19:41:32


Reines
Member
Offline

Topic: [Perl] xChat SysInfo for Windows

I prefer xChat over mIRC, but could not find any sysinfo script for windows for it, so decided to quickly make one. For anyone else using xChat on Windows, here it is (though it might only work properly on Vista).

OS: Microsoft® Windows Vista™ Ultimate
CPU: Intel(R) Core(TM)2 CPU 6600 @ 3420 MHz
Mem: 2046 Mb (1102 Mb used)
GFX: NVIDIA GeForce 8800 GTX 768 Mb
Screen: SyncMaster 940BW/199BW/941BW, SyncMaster Magic CX915BW(Digital) @ 1440x900
HDD: 1424.6 Gb (1152.5 Gb used)

use strict;
use warnings;

my $version = 0.1;

Xchat::register("SysInfo", "$version", "SysInfo", "");
Xchat::print("Loaded SysInfo v$version");
Xchat::hook_command('sysinfo', \&sysinfo);

use Win32::OLE;

my $wmi = Win32::OLE->GetObject('winmgmts:\\\\.\\root\\cimv2');
my $datetime = Win32::OLE->new('WbemScripting.SWbemDateTime');

my $os = $wmi->InstancesOf('Win32_OperatingSystem');
my $procs = $wmi->InstancesOf('Win32_Processor');
my $hdds = $wmi->InstancesOf('Win32_LogicalDisk');
my $gfx = $wmi->InstancesOf('Win32_VideoController');
my $screens = $wmi->InstancesOf('Win32_DesktopMonitor');

sub sysinfo {
    foreach my $cur_os (in $os) {
        $datetime->{Value} = $cur_os->LastBootUpTime;
        Xchat::printf("OS:\002 %s", trim($cur_os->Caption));
        
        foreach my $cur_proc (in $procs) {
            Xchat::printf("CPU:\002 %s\002 @\002 %s MHz", format_procname($cur_proc->Name), $cur_proc->MaxClockSpeed);
        }
        
        Xchat::printf("Mem:\002 %.0f Mb (%.0f Mb used)", $cur_os->TotalVisibleMemorySize / 1024, $cur_os->FreePhysicalMemory / 1024);
        
        foreach my $cur_gfx (in $gfx) {
            Xchat::printf("GFX:\002 %s %.0f Mb @ %.0fx%.0f %.0f Hz", trim($cur_gfx->Caption), $cur_gfx->AdapterRAM / 1048576);
        }
        
        foreach my $cur_screen (in $screens) {
            Xchat::printf("Screen:\002 %s @ %.0fx%.0f", trim($cur_screen->Caption), $cur_screen->ScreenWidth, $cur_screen->ScreenHeight);
        }
        
        my $hdd_total = 0;
        my $hdd_used = 0;
        foreach my $cur_hdd (in $hdds) {
            next if !defined($cur_hdd->VolumeName);
            $hdd_total += $cur_hdd->Size;
            $hdd_used += ($cur_hdd->Size - $cur_hdd->FreeSpace);
        }
        
        Xchat::printf("HDD:\002 %.1f Gb (%.1f Gb used)", $hdd_total / 1073741824, $hdd_used / 1073741824);
    }
    
    return Xchat::EAT_ALL;
}

sub trim {
    $_[0] =~ s/^\s+//;
    $_[0] =~ s/\s+$//;

    return $_[0];
}

sub format_procname {
    $_[0] =~ s/\s+@.+//g;
    $_[0] =~ s/\s+/ /g;
    
    return $_[0];
}

Edit: I'm not too sure about the screen part. I have 2 and it is only returning one for some reason.

.essence
BARDTARDED
Offline

Re: [Perl] xChat SysInfo for Windows

you cant take my joke.

http://i15.photobucket.com/albums/a359/rustinr/backabackabcacbk.png
<Ross>: at 10 i didnt know what supermarket meant
               <Rai1> dude wait         <Rai1> i gotta find that paris hilton song                <Rai1> its banging

Brick Tamland
BARDTARDED
Offline

Re: [Perl] xChat SysInfo for Windows

noobcode

http://upit.cc/images/13b1ec33.gifhttp://upit.cc/images/acbbbddf.png


Akari
The Otaku Fip
Offline

Re: [Perl] xChat SysInfo for Windows

Stupid Reines and his masters degree.

Better to be dead then red.

Unholy
gone
Offline

Re: [Perl] xChat SysInfo for Windows

brad deleted his post or am i tripping

http://img9.imageshack.us/img9/9240/dv4tb.gif

.essence
BARDTARDED
Offline

Re: [Perl] xChat SysInfo for Windows

Unholy wrote:

brad deleted his post or am i tripping

yeah i came back here and his post is gone, he thinks hes crafty or something

http://i15.photobucket.com/albums/a359/rustinr/backabackabcacbk.png
<Ross>: at 10 i didnt know what supermarket meant
               <Rai1> dude wait         <Rai1> i gotta find that paris hilton song                <Rai1> its banging

Brick Tamland
BARDTARDED
Offline

Re: [Perl] xChat SysInfo for Windows

copy cats

http://upit.cc/images/13b1ec33.gifhttp://upit.cc/images/acbbbddf.png

Brad12
BARDTARD SHIT KING
Offline

Re: [Perl] xChat SysInfo for Windows

.essence wrote:
Unholy wrote:

brad deleted his post or am i tripping

yeah i came back here and his post is gone, he thinks hes crafty or something

huh?

http://upit.cc/images/8452ac7d.gif


CHOEDY
BARDTARDED
Offline

Re: [Perl] xChat SysInfo for Windows

.essence wrote:
Unholy wrote:

brad deleted his post or am i tripping

yeah i came back here and his post is gone, he thinks hes crafty or something

brad never posted here wtf you guys on?

http://upit.cc/images/ea6019f2.gifhttp://img14.imageshack.us/img14/6355/qtip2s.jpghttp://upit.cc/images/8b44bb2a.gif
Fuckyourmum