mIRC Home    About    Download    Register    News    Help

Print Thread
#104934 10/12/04 04:06 PM
Joined: Oct 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Oct 2003
Posts: 9
I wish to get a list of working processes on my computer through scripting.
Is this possible?

I've built a command that activates Winrar, and I need it to know when it stops working.

Thanks!

#104935 10/12/04 04:33 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It is possible to get a list of all running processes using $com() and WMI (look at examples #2 and #3 in the help file regarding $com to get an idea). However, before I write such a script for you, you may want to look into an alternative: it is possible to make mirc run a program and wait for it to finish, again using COM objects. This way you don't have to check repeatedly if the program's finished. All you need to do is install this alias and use /xrun -w winrar <arguments> instead of /run winrar <arguments>.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#104936 10/12/04 05:08 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
And if I want to stop winamp from my mIRC, not just know when it has been stopped?

#104937 10/12/04 05:38 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
alias isprocess {
  if ($isid) {
    if ($2 !isnum 1-) { tokenize 32 $$1 1 }
    var %a = a $+ $ticks, %b = b $+ $ticks, %c = c $+ $ticks, %i = 1
    .comopen %a WbemScripting.SWbemLocator
    if ($com(%a)) {
      .comclose %a $com(%a,ConnectServer,3,dispatch* %b)
      if ($com(%b)) {
        .comclose %b $com(%b,ExecQuery,3,string,SELECT Name FROM Win32_Process WHERE Name=" $+ $1",dispatch* %c)
        if ($com(%c)) { 
          if ($comval(%c,$2,Name) == $1) {
            .comclose %c
            return $true
          }
        }
      }
    }
    if ($com(%a)) { .comclose %a }
    if ($com(%b)) { .comclose %b }
    if ($com(%c)) { .comclose %c }
    return $false
  }
}
alias endprocess {
  if ($isid) {
    if ($2 !isnum 1-) { tokenize 32 $$1 1 }
    var %a = a $+ $ticks, %b = b $+ $ticks, %c = c $+ $ticks, %i = 1
    .comopen %a WbemScripting.SWbemLocator
    if ($com(%a)) {
      .comclose %a $com(%a,ConnectServer,3,dispatch* %b)
      if ($com(%b)) {
        .comclose %b $com(%b,ExecQuery,3,string,SELECT Name FROM Win32_Process WHERE Name=" $+ $1",dispatch* %c)
        if ($com(%c)) {
          if ($comval(%c,$2,Name) == $1) {
            .echo -q $comval(%c,$2,Terminate)
            .comclose %c
            return $true
          }
        }
      }
    }
    if ($com(%a)) { .comclose %a }
    if ($com(%b)) { .comclose %b }
    if ($com(%c)) { .comclose %c }
    return $false
  }
}


$isprocess(<process>[,N]) - returns $true if there's an Nth process for <process>, otherwise $false.
$endprocess(<process>[,N]) - returns the same as $isprocess(), but also ends the Nth process for <process>.

Example:

Code:
if ($isprocess(mirc.exe,1)) { .echo -q $endprocess(mirc.exe,1) }


New username: hixxy
#104938 10/12/04 07:46 PM
Joined: Oct 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Oct 2003
Posts: 9
Quote:
It is possible to get a list of all running processes using $com() and WMI (look at examples #2 and #3 in the help file regarding $com to get an idea). However, before I write such a script for you, you may want to look into an alternative: it is possible to make mirc run a program and wait for it to finish, again using COM objects. This way you don't have to check repeatedly if the program's finished. All you need to do is install this alias and use /xrun -w winrar <arguments> instead of /run winrar <arguments>.


Thanks a lot!
It really helped me, and now the script works out just fine!

Thanks again!


Link Copied to Clipboard