Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.62 KB | None | 0 0
  1. alias -l get_printer_locator {
  2.   :a
  3.   if ($com(printer_locator)) .comclose printer_locator
  4.   if ($com(printer_services)) .comclose printer_services
  5.   if ($var(%r,1).local) return %r
  6.   if ($com($2)) .comclose $2
  7.   set -l %r
  8.   .comopen printer_locator WbemScripting.SWbemLocator
  9.   if ($comerr) goto a
  10.   if (!$com(printer_locator,ConnectServer,3,dispatch* printer_services)) && ($comerr) goto a
  11.   if (!$com(printer_services,ExecQuery,3,bstr,Select * from $1,dispatch* $2)) && ($comerr) goto a
  12.   if ($com($2,Count,3)) %r = $com($2).result
  13.   goto a
  14. }
  15.  
  16. alias get_printers {
  17.   set -l %com get_printers
  18.   set -l %n $get_printer_locator(Win32_Printer,%com)
  19.   if (!%n) {
  20.     if ($com(%com)) .comclose %com
  21.     return
  22.   }
  23.   if ($hget(%com)) hfree %com
  24.   hmake %com
  25.   set -l %x 1
  26.   :l
  27.   if (WINPRINT != $comval(%com,%x,PrintProcessor)) hadd %com %x $comval(%com,%x,Default) $comval(%com,%x,Name)
  28.   inc %x
  29.   if (%x <= %n) goto l
  30.   .comclose %com
  31.   if ($isid) return $hget(%com,0).item
  32. }
  33.  
  34. alias print_file {
  35.   set -l %r $false
  36.   if (!$isfile($1)) goto end
  37.   set -l %cmd notepad /PT $qt($1) $qt($2)
  38.   set -l %id $ticks $+ $rand(1111,9999)
  39.   if ($com(pid_shell $+ %id)) .comclose pid_shell $+ %id
  40.   .comopen pid_shell $+ %id WScript.Shell
  41.   if ($comerr) goto end
  42.   if (!$com(pid_shell $+ %id,Run,1,bstr,%cmd,int,0,bool,false)) goto end
  43.   %r = $true
  44.   :end
  45.   if ($com(pid_shell $+ %id)) .comclose pid_shell $+ %id
  46.   return %r
  47. }
  48.  
  49. alias exemplo_printers {
  50.   if ($get_printers) {
  51.     set -l %x $v1
  52.     while %x {
  53.       tokenize 32 $hget(get_printers,%x).data
  54.       echo -a Padrão: $1 Nome: $2-
  55.       dec %x
  56.     }
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement