mIRC Homepage
Posted By: valkenswaard Starting/closing winamp by a trigger - 22/11/04 03:23 PM
Hey peeps ehre is a problem that i need to be solved. I want to start winamp with a trigger like !winampon / !Winampoff. So that winamp.exe is starting at the computer where the script is running. The only problem is i don't now how.
Can some1 post me a line of code that Open en Closes window after writing a trigger down in a chat room.

Thanks in advance

Unreal out
Posted By: LethPhaos Re: Starting/closing winamp by a trigger - 22/11/04 04:34 PM
you need a dll like moo.dll I think
Posted By: tidy_trax Re: Starting/closing winamp by a trigger - 22/11/04 04:44 PM
For !winampon, you can use /run:

Code:
on *:text:!winampon:#:{ run [color:red]full path to winamp.exe[/color] }


For !winampoff, you'll probably need a dll capable of ending processes.
Posted By: LethPhaos Re: Starting/closing winamp by a trigger - 22/11/04 05:23 PM
How solving spaces in that path???
Posted By: tidy_trax Re: Starting/closing winamp by a trigger - 22/11/04 06:09 PM
Two ways:

Code:
on *:text:!winampon:#:{ run [color:blue]$shortfn([/color][color:red]full path to winamp.exe[/color][color:blue])[/color] }


Code:
on *:text:!winampon:#:{ run [color:blue]"[/color][color:red]full path to winamp.exe[/color][color:blue]"[/color] }
Posted By: FiberOPtics Re: Starting/closing winamp by a trigger - 22/11/04 06:35 PM
[*] Download this dll by base, to communicate with Winamp.
[*] Copy the dll to your main mIRC folder.
[*] Add this code to your remotes:

on $*:TEXT:/^!winamp(on|off)$/Si:#: $dll(WA_Link.dll,WA_Link_Command,$iif($regml(1) == off,close,start))

I didn't add any error checking, I expect you to do that yourself. For more info regarding the dll, look here.

Something like this could easily be abused, so you'd better add user permissions, error checking etc.

Greets
Posted By: FiberOPtics Re: Starting/closing winamp by a trigger - 23/11/04 10:00 AM
As an alternative, you could use COM, but it will probably only work on computers which have an NT based OS, like win2k and xp, 2003 etc. The good thing is that you don't need a dll.

Code:
on $*:TEXT:/^!winamp(on|off)$/Si:#: wa_switch $regml(1)
 [color:red]  [/color] 
alias wa_switch {
  if $1 == off {
    .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 = "winamp.exe",dispatch* c) }
    if $com(c) {
      var %a = $com(c,Count,3) 
      while %a { .echo -q $comval(c,%a,Terminate) | dec %a } 
    }
    .comclose c
  }
  else { run $shortfn(full path to winamp.exe) }
}


Greets
© mIRC Discussion Forums