AutoHotkey Community

It is currently May 27th, 2012, 4:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: April 5th, 2010, 8:09 am 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
Does anyone know of a function which will retrieve the PID of a parent process? For example, retrieve the PID of an already running instance of cmd.exe which started a specified process.
Any help would be greatly appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2010, 8:16 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
I am not familar with the operation, but I found these with a quick search.
HTH

http://www.autohotkey.com/forum/topic18550.html

http://www.autohotkey.com/forum/viewtopic.php?t=9000

http://www.google.com/search?hl=en&q=si ... rt=10&sa=N


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2010, 8:33 am 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
Thanks. I think
http://www.autohotkey.com/forum/topic18550.html
has exactly what I was looking for. I did a pretty thorough search of the forum and didn't see that one for some reason.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2010, 7:21 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
Diamond wrote:
Thanks. I think
http://www.autohotkey.com/forum/topic18550.html
has exactly what I was looking for. I did a pretty thorough search of the forum and didn't see that one for some reason.

That's why I included the google search line.
I quite frequently use the site search, that along with "+whatever" can get some pretty exact results.
It is also sometimes more "coherent" in the results it returns. Somtimes not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2010, 7:43 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
In a recent automation project, I found out that a child window of a process has the same PID as the parent process. The child windows were save as and some other app dialogs.

You may be able to verify this by adding specifying a PID in the last parameter of the run command:
Code:
Run, Target , WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID
and then find the PID for the child window by using a mousegetpos loop like this:
Code:
loop {
    mouseGetPos,,, curUID
    winGetTitle, curWIN, % "ahk_id " curUID
    winGet, curPID, PID, % "ahk_id " curUID
    tooltip, % "Current Window is: " curWIN "`nCurrent Pid is: " curPID
    sleep, 100
}
esc::exitapp ; <- Press escape to exit.

I'm assuming that the original command is using comspec (as its cmd.exe). If so, use this to keep the command window open after the command has executed:
Code:
run %comspec% /k ""YourCommand.exe""
Then you can see the PID of the command window plus the child window ;_..

htw

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2010, 7:59 pm 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
TLM wrote:
In a recent automation project, I found out that a child window of a process has the same PID as the parent process. The child windows were save as and some other app dialogs.


Doesn't apply in this case. I am trying to get the PID of the parent process, not the parent window. As far as I know, when an application is started via the console or by another application, it becomes a child process, not a child window which means that they will not have the same process ID. I've already found the function I was looking for in this thread.
http://www.autohotkey.com/forum/topic18550.html
Thanks for the assistance though.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], Yahoo [Bot] and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group