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.








