Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input commands in a exe through cmd.exe and get output in QM
#1
General question:

If I have a certain example.exe (has no GUI) that I can run through cmd.exe and accepts commands through cmd.exe, and outputs also in said cmd.exe. How can I get QM to send commands to example.exe and get the output of example.exe for further use in QM? example.exe is a complex program and should remain active (so not a simple "open example.exe -> input command -> get output from example.exe -> close example.exe", but more like "open example.exe -> input command -> get output from example.exe (-> QM uses this output) -> input command -> get output from example.exe (-> QM uses this output) ->..."

Manually, I would have to right-click and paste the input command in cmd.exe and press enter. When example.exe outputs in cmd.exe -> right-click -> click "mark" -> select the output text in cmd.exe -> press enter to copy it.

How can I do this in QM?

Alternatively, can I run example.exe directly from QM, send commands to it and get its output in QM (while keeping example.exe active)?

Edit: I wonder if it has something to do with this: Capturing output stream from console app ? But I would still need a way to send commands to example.exe :/
#2
Quote:Alternatively, can I run example.exe directly from QM, send commands to it and get its output in QM (while keeping example.exe active)?

Try this class.

Macro ConsoleProcess help
Code:
Copy      Help
;Starts a console process. Can read its output and write input.
;Unlike <help>RunConsole2</help>, allows to capture console output immediately, not when the process ends.

;EXAMPLES in test folder

Macro test ConsoleProcess.WriteStdin
Code:
Copy      Help
out
#compile "__ConsoleProcess"
ConsoleProcess x
x.Exec("$my qm$\console3.exe")
str s
int i
for i 1 1000
,if(!x.ReadStdout(s 2)) break
,out F"<{s}>"
,x.WriteStdin(F"input={i}")

Function console3
Code:
Copy      Help
;/exe

;Console .exe for macro "test ConsoleProcess.WriteStdin".


str s
ExeConsoleWrite "waiting for input 1"
ExeConsoleRead s
mes s "Console"
ExeConsoleWrite "waiting for input 2"
ExeConsoleRead s
mes s "Console"

;BEGIN PROJECT
;exe_file  $my qm$\console3.exe
;flags  70
;END PROJECT


Attached Files
.qml   ConsoleProcess.qml (Size: 9 KB / Downloads: 371)
#3
Tnx,

I will try this this evening and let you know the result.


Forum Jump:


Users browsing this thread: 1 Guest(s)