mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
im wondering if it is possible to do..
when i type !kick <nick> <reason> in mirc channel like this:



then , it will send the command into cmd promt like this:



can anyone make me a code for this one ?
the soldat server is running.

and when i tried this code:
Code:
on *:text:!kick*:#:{
  if $nick($chan,$$2,a,o) && $$3 {
    .kick $chan $$2-
    .run cmd.exe /k
  }
}


what happen is, it opens new cmd prompt. frown
and it doesn't send the kick command in my soldat server. frown
help.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sending that command to cmd.exe wouldn't help you, as soldatserver.exe is different from cmd.exe.
I have no idea if - by any chance - it would be possible to run the soldatserver.exe with all required params - something like "run soldatserver.exe -<switches> <your parameters/commands>".

Another sollution may be using 2 aliases (that I didn't create but found here - dunno who originally created them), that should allow you to
1) make soldatserver.exe the active application (if it ain't already) via "/appactivate soldatserver.exe"
and then
2) send a string of keystrokes to that window, i.e.: enter and execute the kick command: "/sendkeys <your kick command here>{ENTER}"

In addition a third alias (a modification of a $proc alias by myggan ), to see if a specific process is running: if ($isrun(soldatserver.exe) == $true)

Code:
on *:text:!kick*:#yourchannel:{
  if ($2 isop $chan) { notice $nick Ops cannot be kicked. }
  elseif ($2 !ison $chan) { notice $nick $2 is not at $chan $+ . }
  elseif (!$3) { notice $nick Syntax Error: !kick <name> <reason> }
  else {
    kick $chan $2-
    if ($isrun(soldatserver.exe) == $true) {
      appactivate soldatserver.exe
      sendkeys /kick $2- $+ {ENTER}
      notice $nick $2 has been kicked out of the game.
    }
    else { notice $nick soldatserver isn't running. }
  }
}

alias -l sendkeys { .comopen a WScript.Shell | .comclose a $com(a,SendKeys,3,*bstr,$$1-) }

alias -l appactivate { .comopen a WScript.Shell | .comclose a $com(a,AppActivate,3,*bstr,$$1-) }

alias -l isrun {
  if (($isid) && ($1 != $null)) {
    if ($com(isrun_a)) { .comclose isrun_a }
    if ($com(isrun_b)) { .comclose isrun_b }
    .comopen isrun_a WbemScripting.SWbemLocator
    if (!$com(isrun_a)) { return }
    .comclose isrun_a $com(isrun_a,ConnectServer,3,dispatch* isrun_b)
    if (!$com(isrun_b)) { return }
    .comclose isrun_b $com(isrun_b,ExecQuery,3,string,SELECT ProcessId FROM Win32_Process WHERE Name = $qt($1) $+ ,dispatch* isrun_a)
    if (!$com(isrun_a)) { return }
    noop $com(isrun_a,Count,3)
    var %return = $iif(($com(isrun_a).result),$true,$false)
    .comclose isrun_a
    return %return
  }
}


Edit: changed the output to notices


Last edited by Horstl; 09/11/08 08:18 PM.
Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
hi Horstl,
thanks for your fast response here..
the code is quite pretty and cool.
but the problem is, it don't send a /kick $2 $3- command in the game server.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Well, I don't have a soldatserver.exe, it's up to you to check the individual parts.

EDIT: To run some tests, you'll have to remove the three "-l" in front of the alias names, in the code above.
That is: change "alias -l sendkeys { ..." to "alias sendkeys { ..."; do the same with "alias appactivate" and "alias isrun".


1) does the $isrun-check work for you?
I tested with cmd.exe and some other apps.
while soldatserver.exe is running, type in any mIRC window:
Code:
//echo -a $isrun(soldatserver.exe)
It should return $true if it's running, $false if it aint running. In addition, try "soldatserver" instead of "soldatserver.exe". Test other applications, like:
Code:
//echo -a $isrun(cmd.exe) | run cmd.exe | echo -a $isrun(cmd.exe)


2) does /appactivate work for you?
Type in any mIRC window:
Code:
/appactivate soldatserver.exe
Is soldatserver.exe now the active app? If not, try "soldatserver" instead of "soldatserver.exe" (For example with Firefox, it's working for "appactivate firefox", but not for "appactivate firefox.exe".)


3) does /sendkeys work for you?
the command is "typing" keystrokes to the active app. Thus, while in mIRC:
Code:
/sendkeys /echo -a test{enter}
Should result in the word "test" echoed to your mIRC window.
You can play arround with these commands, e.g. sending keystrokes for testing purposes to apps, like:
Code:
//appactivate cmd.exe | sendkeys ipconfig{enter}
(if cmd.exe is already running, should trigger the ipconfig output there)

Something I forgot in the original post: to reset focus "back" to mIRC, you can use appactivate again, or the in-build command "showmirc -s".

Last edited by Horstl; 10/11/08 11:17 PM.
Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
hi again..
i changed the aliases based of what you have said on your reply.
when i type //echo -a $isrun(soldatserver.exe)

it says:
-
* /echo: insufficient parameters
-

same thing with "//echo -a $isrun(cmd.exe) | run cmd.exe | echo -a $isrun(cmd.exe)"

in "/appactivate soldatserver.exe",
it says:
-
APPACTIVATE Unknown command
-
same thing with "/sendkeys"

in "//appactivate cmd.exe | sendkeys ipconfig{enter}"
it says.
-
APPACTIVATE Unknown command
-
-
SENDKEYS Unknown command
-

-----------------

your code is good,
our problem here is to sendkey to the cmd prompt/server.


Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
A little modification of the code - but if you did remove the three -l and got "unknown command" errors, you either mixed up something with the brackets, or you didn't load the file properly to "soldatbot"

To play safe:
1) remove (e.g. unload) the previously given script and your "own" soldatserver-kick-script as well
2) add the script below to the remotes of the "bot" client: Alt-R opening the scripts editor, in tab "remote" create a new file and paste all the code below
3) put the name of your channel for #YOURCHANNEL (line 1)
4) "save" or "save as ..." the new file and close the scripts editor
5) make sure remotes are enabled: type /remote on
6) make sure "com" isn't locked in this client. go to tools -> options -> other -> lock: if the box "com" is checked at "disable commands", uncheck it.
7) make sure the bot-client running this script is opped in the channel you put for #YOURCHANNEL

Code:
on @*:text:!kick *:#YOURCHANNEL:{
  var %app = soldatserver.exe
  if ($2 isop $chan) { notice $nick Ops cannot be kicked. }
  elseif ($2 !ison $chan) { notice $nick $2 is not at $chan $+ . }
  elseif (!$3) { notice $nick Syntax Error: !kick <name> <reason> }
  else {
    kick $chan $2-
    if ($isrun(%app) == $true) {
      sendtoapp %app /kick $2- {ENTER}
      notice $nick $2 has been kicked out of the game.
    }
    else { notice $nick %app isn't running. }
  }
}

alias -l sendtoapp {
  if ($2) {
    if ($com(sta)) { .comclose sta }
    .comopen sta WScript.Shell 
    noop $com(sta,AppActivate,3,*bstr,$1)
    .comclose sta $com(sta,SendKeys,3,*bstr,$2-)
    showmirc -s
  }
}

alias -l isrun {
  if (($isid) && ($1 != $null)) {
    if ($com(isrun_a)) { .comclose isrun_a }
    if ($com(isrun_b)) { .comclose isrun_b }
    .comopen isrun_a WbemScripting.SWbemLocator
    if (!$com(isrun_a)) { return }
    .comclose isrun_a $com(isrun_a,ConnectServer,3,dispatch* isrun_b)
    if (!$com(isrun_b)) { return }
    .comclose isrun_b $com(isrun_b,ExecQuery,3,string,SELECT ProcessId FROM Win32_Process WHERE Name = $qt($1) $+ ,dispatch* isrun_a)
    if (!$com(isrun_a)) { return }
    noop $com(isrun_a,Count,3)
    var %return = $iif(($com(isrun_a).result),$true,$false)
    .comclose isrun_a
    return %return
  }
}


Now, if a user types "!kick <somenick> <somereason>", he should reveive one of the possible notices: ops cant be kicked/<nick> is not at <chan>/<nick> has been kicked/soldatserver isnt running

If he's receiving the "isnt running" message and you're sure soldatserver.exe IS running at the system of the "botclient", try again after changing the 2nd line:
Code:
  var %app = soldatserver.exe
to
Code:
  var %app = soldatserver


As I don't have a soldatserver.exe, I tested with cmd.exe, and it worked like expected smile

_____________
EDIT:
looking at the topic you put in one of the screens above: if you want to restrict the !kick command to ops or voices only, add above this line:
Code:
if ($2 isop $chan) { notice $nick Ops cannot be kicked. }
that line (limiting !kick to ops):
Code:
if ($nick !isop $chan) { return }
or that line: (limiting !kick to voices)
Code:
if ($nick !isvoice $chan) { return }


Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
sir,
no problem about all the codes..
the only problem is the sending of commands or let say "letters" in the cmd prompt....

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sorry to say if you don't provide more details on what you tried and on what happened, no one will be able to help you.

- did you follow the steps above?
- does the script kick the user out of the channel? is there a notice sent after the kick? what kind of notice?
- do you get any error messages again?
- did you try "soldatserver" instead of "soldatserver.exe"?
- is there any activity in the prompt (window) of soldatserver.exe?
- if you run cmd.exe (/run cmd) and instead of "soldatserver.exe" you put "cmd.exe" for %app, does it send the command to the window of cmd.exe?

Finally, what System and what mIRC version are you running this at?

Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
i followed what you're instructed to me..
i tried to change the soldatserver.exe to cmd.exe , and try to do the !kick command,
it works.. and it sends my /kick $nick in the cmd.exe,
but in soldatserver.exe , it doesn't...

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Weird... you did type the /kick command (screenshot; initial post) to that window of soldatserver.exe ? As there's a text that runs "please command the server using the soldat admin program"...

Joined: Nov 2008
Posts: 17
V
VictriX Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Nov 2008
Posts: 17
no, i just edit it in paint..
and if you notice, the font there is too big compared to the default font size of the cmd.exe

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
[out of words]... - sorry, we both spent some precious time trying to send an input (command) to a window that does not accept inputs at all... (and I have no clue how the "soldat admin program" is working)


Link Copied to Clipboard