mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
content of a batch file to mirc #248348 04/10/14 07:09 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
Hi everyone smile

My first post and i start searching for help. Hopefully someone of u can help me smile
Im running a batch file on windows 7. This batch file creates a .txt file, where i need the content of it automatically sent to my miRC (only this way is needed). Is there any way to get through this ?
Any help is appreciated. Many thanks!
greets


Re: content of a batch file to mirc [Re: one4two] #248351 04/10/14 08:36 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
I am not 100% sure for this but the mIRC support DDE read about it may you will find that you need.

Use: /help dde

- Thanks!

Re: content of a batch file to mirc [Re: one4two] #248352 04/10/14 08:50 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Does the batch file have to create a text file or could you change it so that it ECHOs the output instead? There is a way to obtain ECHO results using mIRC which I'd be happy to help with.

Re: content of a batch file to mirc [Re: hixxy] #248354 04/10/14 09:09 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
No need to create the txt file. i can use echo %output% in my batch file.

Im very excited for ur answer

Last edited by one4two; 04/10/14 09:10 PM.
Re: content of a batch file to mirc [Re: one4two] #248362 05/10/14 10:10 AM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Script:

Code:
alias -l raiseerror { 
  echo -a $1-
  halt
}
alias runbat_close { 
  if ($com(wscript)) { .comclose $v1 }
  if ($com(wscript.exec)) { .comclose $v1 }
  if ($com(wscript.exec.stdout)) { .comclose $v1 }
  if ($1 != -h) && ($hget(runbat)) { hfree $v1 }
}
alias runbat {  
  if (!$isid) { 
    if ($com(wscript)) || ($com(wscript.exec)) || ($com(wscript.exec.stdout)) { raiseerror * /runbat: A batch file already appears to be executing. Please wait for it to finish or use /runbat_close }
    if (*.bat !iswm $1-) { raiseerror * /runbat: Please specify a valid batch file. }
    if (!$isfile($1-)) { raiseerror * /runbat: File $qt($1-) does not exist. Please specify a valid batch file. }
    if ($nopath($1-) == $1-) { tokenize 32 $mircdir $+ $1- }
    if ($hget(runbat)) { hfree $v1 }
    .comopen wscript wscript.shell
    if (!$comerr) {
      noop $com(wscript,Exec,3,bstr,$1-,dispatch* wscript.exec)
      if (!$comerr) {
        noop $com(wscript.exec,StdOut,3,dispatch* wscript.exec.stdout)
        if (!$comerr) {
          noop $com(wscript.exec.stdout,ReadLine,3)
          var %i = 1
          while ($com(wscript.exec.stdout).result != $null) {
            hadd -m runbat %i $v1
            noop $com(wscript.exec.stdout,ReadLine,3)
            inc %i
          }
        }
      }
    }
    runbat_close -h
  }
  else { return $hget(runbat,$1) [ $+ [ $iif($1 == 0,.item) ] ] }
  return
  :error
  runbat_close
}


Example of use:

Code:
alias test {
  runbat test.bat
  var %i = 1
  while ($runbat(%i) != $null) {
    echo -a $v1
    inc %i
  }
  runbat_close
}


/runbat <batch file> - runs the batch file and it will record the output in a hashtable called 'runbat'
$runbat(<N>) - returns the Nth line from the hashtable (you can use <N> = 0 to get the number of returned lines)

/runbat_close -h - cleans up the script by closing the COM objects used but retains the hashtable.
/runbat_close - cleans up the script including deleting the hashtable.

The example will only work if 'test.bat' exists in your mIRC directory.

You should use /runbat_close once you're done with what you need to do so that the hashtable is cleaned up.

Re: content of a batch file to mirc [Re: hixxy] #248366 05/10/14 12:09 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
Im very thankful for your help, but: maybe i didnt explain very well. So sorry.

The .batch file isnt called within mirc. Another program creates this batch file. And when this .batch file is created i want its content sent from outside miRC to my miRC.

Is this possible ? smile

Re: content of a batch file to mirc [Re: one4two] #248367 05/10/14 12:18 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Originally Posted By: one4two
Im very thankful for your help, but: maybe i didnt explain very well. So sorry.

The .batch file isnt called within mirc. Another program creates this batch file. And when this .batch file is created i want its content sent from outside miRC to my miRC.

Is this possible ? smile


Ahh I see.

You'd need to check the file on a timer and see if it has changed.

Re: content of a batch file to mirc [Re: hixxy] #248368 05/10/14 12:24 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
I was hoping i could avoid using a timer. I want the message instantly without any delay. So i need to run a timer like check every second smirk

Re: content of a batch file to mirc [Re: one4two] #248370 05/10/14 12:43 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
If you made the program yourself you could have it communicate with mIRC using DDE or SendMessage, otherwise you'll just have to poll for updates using a timer.

Re: content of a batch file to mirc [Re: hixxy] #248372 05/10/14 01:17 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
Nope - sadfully not. All i can do is letting the batch file run.

Anyway: Many thanks for helping me!

edit: Theres only a run program option. Means i can do what ever command i'd like

Last edited by one4two; 05/10/14 01:35 PM.
Re: content of a batch file to mirc [Re: one4two] #248374 05/10/14 02:52 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
If it lets you use command line parameters then you could catch those using mIRC like so:

Code:
on *:start:{ echo -a CMD LINE : $cmdline }


So you could tell it to run e.g. "C:\program files\mIRC\mirc.exe" batch_finished

Code:
on *:start:{
  if ($cmdline == batch_finished) { ; Do stuff with the batch file ... }
}


The only problem with this is it will run a new copy of mIRC each time rather than the currently running one.

Re: content of a batch file to mirc [Re: hixxy] #248401 07/10/14 08:06 AM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
hm^^

i was hoping there's a way like ddecmd.exe -> miRC COMMAND
or if there's .. i havent found.

Re: content of a batch file to mirc [Re: one4two] #248402 07/10/14 08:33 AM
Joined: Jul 2006
Posts: 3,621
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,621
If you have no control over the batch file nor over the program creating the batch file, you are forced to check the content of the file created by the batch file from mIRC using a timer. You can use a millisecond timer so it wouldn't have a noticeable delay.
The only thing you need now is a way to identify when you have 'new content' and when the batch file finished writting the new content, or similar.

Edit: If you can run a program when the batch file is done, then you should run a program which will communicate with mIRC, I don't know much about batch file so I don't know if you can either use DDE/sendmessage from it (doubt it) but you could call a custom program made by you which would communicate with mIRC

Last edited by Wims; 07/10/14 08:36 AM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: content of a batch file to mirc [Re: Wims] #248403 07/10/14 10:09 AM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
Exactly what im looking for. A runable file to send a cmd to mirc.

Same written here: http://forums.mirc.com/ubbthreads.php/topics/247471/Re:_Executing_Mirc_Script_From

So if there's a lets call it dde.exe (client to talk to mirc) i'd would have the following:
dde.exe /dde mirc command "" /msg # %output

Last edited by one4two; 07/10/14 10:20 AM.
Re: content of a batch file to mirc [Re: one4two] #248404 07/10/14 10:25 AM
Joined: Jul 2006
Posts: 3,621
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,621
I take it you don't know how to make that dde.exe?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: content of a batch file to mirc [Re: Wims] #248405 07/10/14 10:36 AM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
well yeah

i found ddecmd and when im trying:

C:\Program Files (x86)\DDE Command>ddecmd execute -s mirc -t COMMAND --command /dde mIRC command "" msg #he hello

i get * /dde: insufficient parameters

so there is a connection to mirc

/msg #he hello is not working... getting the following error:
dde mIRC command "" /msg #he hello
ERROR: Invalid command line switch '/msg'

im soooo close


Last edited by one4two; 07/10/14 10:36 AM.
Re: content of a batch file to mirc [Re: one4two] #248406 07/10/14 11:18 AM
Joined: Jul 2006
Posts: 3,621
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,621
What?

Well I don't have that executable, but /dde mIRC command "" msg #he hello has all the required parameters, this command cannot throw the error you gave. One thing is that you didn't use /msg, meaning that mIRC will put "msg #he hello" in the editbox and hit enter, resulting in "* you are not connected", if you are not connected, for example. So use /msg there.

In which situation do you get ERROR: Invalid command line switch '/msg' ? from the ddecmd executable?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: content of a batch file to mirc [Re: Wims] #248407 07/10/14 12:08 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
exactly, when i use:

C:\Program Files (x86)\DDE Command>ddecmd execute -s mirc -t COMMAND --command /dde mIRC command "" /msg #he hello

ERROR: Invalid command line switch '/msg'

Ive added the file:
ddecmd

Re: content of a batch file to mirc [Re: one4two] #248408 07/10/14 12:18 PM
Joined: Jul 2006
Posts: 3,621
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,621
Right, this is the windows shell interpreting /anythinghere as an option to the executable, I don't know enough about the windows shell, you need to escape that '/'

The escape sequence/character is the ^, try C:\Program Files (x86)\DDE Command>ddecmd execute -s mirc -t COMMAND --command /dde mIRC command "" ^/msg #he hello

Last edited by Wims; 07/10/14 12:20 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: content of a batch file to mirc [Re: Wims] #248409 07/10/14 12:23 PM
Joined: Oct 2014
Posts: 16
O
one4two Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Oct 2014
Posts: 16
sadfully not - any other ideas ? smile

maybe theres another ddecmd whatever

Last edited by one4two; 07/10/14 12:33 PM.
Page 1 of 2 1 2