Requested by: Unknown
Contact: http://westor.ucoz.com/contact
Credits to: Wims
Description:
This code is checking if you have internet connection available via mIRC, if you get 1 on $internet return that means that you have internet connection if you get 0 on return that means that you have NOT an internet connection, NOTE that if on the first time you use $internet may stuck for a while to find the correct internet adapter that your machine uses to check for internet connection but this will happen only one time per mIRC open.
Example 1: //echo -a Internet Connection: $internet
Example 2: //echo -a My Internet Connections is: $iif($internet,Connected,NOT Connected)
ON *:START: { internet }
alias internet {
var %h = $hget(INTERNET,CON)
if (%h) {
var %s = $wmiget(Win32_NetworkAdapter,%h).NetConnectionStatus
if (%s) && (%s == 2) { $iif($isid,return 1,return) }
else { $iif($isid,return 0,return) }
}
elseif (!%h) {
var %t = $wmiget(Win32_NetworkAdapter,N).NetConnectionStatus
if (!%t) { $iif($isid,return 0,return) }
var %i = 1
while (%i <= %t) {
var %s = $wmiget(Win32_NetworkAdapter,%i).NetConnectionStatus
hadd -m INTERNET CON %i
if (%s) && (%s == 2) { $iif($isid,return 1,return) }
inc %i
}
}
$iif($isid,return 0)
}
alias wmiget {
var %ar = a $+ $ticks $+ $ctime
var %br = b $+ $ticks $+ $ctime
var %cr = c $+ $ticks $+ $ctime
.comopen %ar WbemScripting.SWbemLocator
if ($comerr) { .comclose %ar | return 0 }
.comclose %ar $com(%ar,ConnectServer,3,dispatch* %br)
if ($comerr) { return 0 }
.comclose %br $com(%br,ExecQuery,3,bstr*,select $prop from $1,dispatch* %cr)
var %x = $comval(%cr,$iif($2,$2,1),$prop)
:error
if ($com(%ar)) { .comclose %ar }
if ($com(%br)) { .comclose %br }
if ($com(%cr)) { .comclose %cr }
return $iif(%x,%x,0)
}