Can I run a command in another app using C++? - c++

I'm not sure if anyone asked this, I tried to find it but I couldn't. I'm starting a new project and I want to make a GUI in C++ that will run another application called "GAMS" which does some optimization problems for me.
Now, I do know how to create GUI and how to run GAMS itself using ShellExecute(), but I don't know how to run those algorithms from my GUI.
All I need is to run scrip that I wrote in GAMS and that I would be able to manipulate with data that I receive from GAMS.
So my question is, can I send commands from my GUI to GAMS?
Thanks in advance!!

Related

How to emulate keyboard input under Wayland in C++?

I'm trying to send a keyboard input from a C++ application (I'm using Qt5 framework). I successfully run ydotool as external QProcess but I'm searching for a better and more "c++" way of doing this, without using external modules (ydotool needs a runtime run as root and each command must be run as root too, it needs some work to make it work correctly, I'd like something simpler from the user side).
Any idea?
thanks in advance!

Qt automatic testing of console application

I'm currently working on a console application with Qt, and I was wondering, if there is any way to automatically test my application, so I don't have to test everything manually. I've searched the web, but haven't found anything yet.
If there is no way to do this with a preexisting framework, would it be possible to have an extra thread writing to, and reading from stdin and checking on this thread if the program is behaving correctly? If yes, how exactly would I do this? (I'm a beginner at everything multithreading)
Thanks in advance.

Create a QML plugin to run system commands?

I'd like to run commands and show the output in quite a few Ubuntu Touch apps I'd like to create, so therefore I need to create a plugin for QML in C/C++(?) with this functionality.
The thing is that I don't know anything about C/C++, nor do I really want to learn it. However I do need it now and I need help to get going.
How would I create this plugin? Where do I start?
Thanks in advance,
Daniel
You can always wrap QProcess which allows you to run any shell command.
Check this out
And for Ubuntu touch you can use wizard for qml plugins. Its quite easy actually.
I got help from Joseph Mills: https://code.launchpad.net/~josephjamesmills/+junk/launchTotem
You shall use PlasmaCore.DataSource with the engine "executable", as in this example.
Mind that the call is asynchronous. Hence the command sends a signal when it finishes, and a different part of the code picks the signal and continues with the next step you want to perform.

Running a terminal via QT

I am a beginner is C++. I am trying to find, is it possible to run my program in both in QT window and Linux based. When the user logins into my system, the user can select GUI or terminal mode to run the system.
Thus, I would like to know is it possible to do it. If possible how can I proceed on? What command should I use to switch from a QT window to a terminal?
Do I need to create a separate set of project for both individually or using the same set of classes?
All Linux programs (unless explicitly disabled) print out text to a terminal. If you run the program in a graphical environment you will probably not run it from a console, therefore you won't see the output, but it will be still there.
If you want your program to be usable from a console, just test whether you could create the main window and if not, fallback to simple text output.
Note that the binary will still require the X server and Qt libraries to be installed.
You can construct your application with or without the GUI enabled through the QApplication constructor. Consult the example in Qt's documentation:
http://qt-project.org/doc/qt-4.8/qapplication.html#QApplication-2
Though, it should be noted that everything in Let_Me_Be's response is correct. In fact, the Qt example does exactly what he's suggesting. Please take the time to understand his answer before you plunge into coding.

Ahk script and C++ communication

I wish to use the functions of autohotkey within a C++ program.
I am currently running my scripts triggered by the c++ program- I just run them as a .bat file. This works well but the problem is that I cannot return values from the script to the c++ program.
I wish to be able to read the position of the mouse from the script and make decisions based upon this in my C++ program. My scripts do quite complex things- so doing this in autohotkey is the best solution for me- I have knowledge of C, but little of C++.
I have read about the Autohotkey .DLL - I know how to trigger it but not how to read values from it. If anyone could instruct me or even post example code of a .dll being loaded and a value sent to a script and a value returned- I would be eternally grateful!!
I have spent hours on this and to no avail!
to return a value, could this possibly work http://www.autohotkey.net/~tinku99/ahkdll/functions/ahkgetvar.htm
I'm not sure about the dll, but you could just write your own application in Autohotkey and package it along with your C++.
The communication takes place over a hidden window with an edit control and a button. You use one application to set text in the edit box, and then to click the submit button. The other application owns the window can process whatever is put into the edit control - as if you were passing a variable. Basically, that's it.
Check out this thread where I've explained it in more detail: How to send a command to a running application via commandline
Now, that's not quite what you wanted, but the effect is the same, and you already know all the api.