Christopher Blue 0 Posted November 7, 2004 For the purposes of my AutoIt killer script, I need to know how to find the PID of the script itself so that it may refrain from killing itself until the job is done. Share this post Link to post Share on other sites
Jos 2,170 Posted November 7, 2004 For the purposes of my AutoIt killer script, I need to know how to find the PID of the script itself so that it may refrain from killing itself until the job is done.<{POST_SNAPBACK}> I am wondering what the reason for the sudden explosion of post in the "Scripts and Scrapts" forum for regular support is..... Must be 'Script and Scraps" day .... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Christopher Blue 0 Posted November 7, 2004 I must have posted this in the wrong place then. Would an admin please move it to v3 Support? Share this post Link to post Share on other sites
Christopher Blue 0 Posted November 7, 2004 Here is something interesting. I shall read more into it. Share this post Link to post Share on other sites
Jos 2,170 Posted November 7, 2004 Here is something interesting. I shall read more into it.<{POST_SNAPBACK}>This should do it:$pid = DllCall("kernel32.dll","int","GetCurrentProcessId") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Christopher Blue 0 Posted November 7, 2004 Thank you JdeB! I tried: $pid = DllCall ( "kernel32.dll", "Int", "GetCurrentProcess", "ptr", "") but it failed probably because I tried passing a parameter. I thought I had to because the DLLCall documentation doesn't list parameters as optional. Share this post Link to post Share on other sites
Jos 2,170 Posted November 7, 2004 Thank you JdeB! I tried:$pid = DllCall ( "kernel32.dll", "Int", "GetCurrentProcess", "ptr", "")but it failed probably because I tried passing a parameter. I thought I had to because the DLLCall documentation doesn't list parameters as optional.<{POST_SNAPBACK}>It is optional .....i guess the helpfile should state: DllCall ( "dll", "return type", "function"[, "type", param ]) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Clemens 0 Posted March 26, 2009 Sry, for this really late thread push ... but it's the only (one line) hint for realise "getting a program's own PID" The code looks really good... but when I've the mini prog $pid = DllCall("kernel32.dll","int","GetCurrentProcessId") sleep(1000) msgbox(0, "my_id", $pid) the result is an empty msgbox any idea? Share this post Link to post Share on other sites
AdmiralAlkex 125 Posted March 26, 2009 If you want to get the scripts own PID then you can use the macro @AutoItPID MsgBox(0, "", @AutoItPID) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Share this post Link to post Share on other sites
Clemens 0 Posted March 27, 2009 Wow, that was easy ... and I didn't find it on my own However... thanks a lot! Share this post Link to post Share on other sites
AdmiralAlkex 125 Posted March 27, 2009 Wow, that was easy ... and I didn't find it on my own However... thanks a lot! Well to your defence it would have been the twelfth result if you search the helpfile for "pid" BTW if you still want to know why your call to "GetCurrentProcessId" didn't work, then read the "Remarks"-section in the helpfile about DllCall or run this code, I think you will get it. $pid = DllCall("kernel32.dll","int","GetCurrentProcessId") sleep(1000) MsgBox(0, "my_id", "PID from GetCurrentProcessId: " & $pid[0] & @CRLF & "PID from @AutoItPID macro: " & @AutoItPID) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Share this post Link to post Share on other sites