PDA

View Full Version : How to command other process?



Momergil
26th June 2012, 14:45
Hello!

I want to create a software that externaly controls other softwares. I know that QProcess is certanly a class that I'm gonna use sometime, but given what I read on its help files I'm not sure it has what I need:

* the possibility to check if the process is running or stoped (stoped == stoped or simply 'not answering')
* the possibility to manipulate the software without having to start it by my software (in other words, I should be able to run it, stop it, command it etc. while not having to start it by my application; it should rather start by the user's choice, and as far as I know QProcess only allows for the user to command the software in question if that one is started with QProcess)
* the possiblity to see the software's parameters (such as how much RAM memory it's consuming)
* (I think the most difficult part) To see if the software is currently being used (i.e. the user is doing something with it) or it is simply opened, with nobody actually using it.

So can I do all this with QProcess (as far as I know, not)? In case the answer being "no", what more will I have to use? And in case "yes", how exactly should I do it? (Because I couldn't figured it out).


Thanks!

Momergil

amleto
26th June 2012, 16:36
you are correct - you cannot do all of that with QProcess. I'm not sure you can even do it with Qt.

I think you will have to look elsewhere for process attaching and process resource info

Momergil
27th June 2012, 20:45
Well, that's not good news. But what of my list can I do with QProcess?

amleto
27th June 2012, 21:38
if we ignore 'not answering' because it doesn't mean much, then QProcess can tell you if a process has stopped or not. And thats it.

ChrisW67
28th June 2012, 05:36
he possibility to manipulate the software without having to start it by my software (in other words, I should be able to run it, stop it, command it etc. while not having to start it by my application;
I am puzzled how you can expect to "be able to run it" without starting it with your application. Is this some unusual interpretation of "run it"?

Anyway to control an entire machine full of foreign processes, which is what you are asking for, is inherently platform specific and intimately tied to security model of the operating system allowing you to do this. You will have to use the appropriate operating system API to do the vast majority of what you ask.

wysota
28th June 2012, 08:16
Provided that the other application was written using Qt and provided that you are able to inject some code into the application, it might be possible to do most of what you want with Qt. However, as Chris mentioned, this is very platform specific.

Momergil
28th June 2012, 20:03
if we ignore 'not answering' because it doesn't mean much, then QProcess can tell you if a process has stopped or not. And thats it.

Actually, it means to me :P I have to know if a process ist not answering for a good time, so my app will reset it. Now, how exactly can I know if a process has stopped or not with QProcess?


I am puzzled how you can expect to "be able to run it" without starting it with your application. Is this some unusual interpretation of "run it"?

hehe, I guess yes! xD Essentially: I must be able to have entire control over the software (as far as it allows me, of course) without having any dependency of that one over my app (so, e.g., if my app crashes and is closed, that software will continue working as if nothing happened since there must be no dependecies, only momentarely interventions).


Anyway to control an entire machine full of foreign processes, which is what you are asking for, is inherently platform specific and intimately tied to security model of the operating system allowing you to do this. You will have to use the appropriate operating system API to do the vast majority of what you ask.

Hmm, as I was figuring out.


Provided that the other application was written using Qt and provided that you are able to inject some code into the application, it might be possible to do most of what you want with Qt. However, as Chris mentioned, this is very platform specific.

Actually, at least for the time being, it's not written in Qt. But I imagine that this app will be later transformed into one that should have no IDE limitations.

-------
Conclusion, then:

It's better to forget using QProcess, because even if I use it I'll not be able to do everything I want with it, so I'll have to use the OS API anyway - so better write evertyhing using the API functions.

So now the only problem is to make that work (http://www.qtcentre.org/threads/49695-Problem-with-include-quot-windows-h-quot?p=223231).


Well, thanks!


Momergil

wysota
28th June 2012, 21:50
I have to know if a process ist not answering for a good time
Not answering to whom?


Now, how exactly can I know if a process has stopped or not with QProcess?
QProcess will emit the finished() signal when the inferior exits.



Actually, at least for the time being, it's not written in Qt.
In that case I have no idea why are you asking those questions on a Qt forum.


But I imagine that this app will be later transformed into one that should have no IDE limitations.
I don't see what IDE has anything to do with this.

Momergil
29th June 2012, 15:24
Not answering to whom?

You know, when you are using Windows and suddently the software in use don't answer anymore, you click it with the mouse or try keyboard shortcuts and nothing happends, than the up-border bar put "... (Not Responding)".


In that case I have no idea why are you asking those questions on a Qt forum.
The software I initially want to communicate with is not written in Qt, but the software I want to create and that will have this control over the other will be written in Qt.


I don't see what IDE has anything to do with this.

Well, you sad:
Provided that the other application was written using Qt (...)
, what seems to mean that IDE do have something to do with this :)

high_flyer
29th June 2012, 16:16
what seems to mean that IDE do have something to do with this
How so?
You can develop Qt applications with a text editor, and a command line.
IDE is not necessary at all, and you can use any available IDE you like.

wysota
30th June 2012, 06:11
You know, when you are using Windows and suddently the software in use don't answer anymore, you click it with the mouse or try keyboard shortcuts and nothing happends, than the up-border bar put "... (Not Responding)".
And the technical definition of the situation is...?


The software I initially want to communicate with is not written in Qt, but the software I want to create and that will have this control over the other will be written in Qt.
But you want to instrument that other software and you need to know how to do it. I don't understand why people expect Qt to be a swiss army knife that has built-in solutions for everything. It's an application framework, for God's sake...



Well, you sad:
, what seems to mean that IDE do have something to do with this :)
"Qt" is a "library" (or actually a set of them), not an "IDE".