mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
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


Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
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!


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

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.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

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

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

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

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

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.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

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.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
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: https://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.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I take it you don't know how to make that dde.exe?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
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.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
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

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
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

Link Copied to Clipboard