nullschritt Posted July 25, 2013 Share Posted July 25, 2013 Hello, I have searched the forums for an answer but can't seem to find one. Is it possible to get the PID of a process using the title or handle of a window? Link to comment Share on other sites More sharing options...
Edano Posted July 25, 2013 Share Posted July 25, 2013 (edited) Retrieves the identifier of the thread that created the specified window #include <WinAPI.au3> _WinAPI_GetWindowThreadProcessId($hWnd, ByRef $iPID) . if it is a childprocess, you can give it a variable $PID on creation (ref. to your previous posting) Edited July 25, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
JohnOne Posted July 25, 2013 Share Posted July 25, 2013 I don't believe you put ByRef in a function call though. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Edano Posted July 25, 2013 Share Posted July 25, 2013 (edited) Func _WinAPI_GetWindowThreadProcessId($hWnd, ByRef $iPID) Local $aResult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hWnd, "dword*", 0) If @error Then Return SetError(@error, @extended, 0) $iPID = $aResult[2] Return $aResult[0] EndFunc ;==>_WinAPI_GetWindowThreadProcessId . . Return Value Returns the Thread ID of the specified window .. helpfile is wrong on this detail. return value is False or True. Edited July 25, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
JohnOne Posted July 25, 2013 Share Posted July 25, 2013 Indeed, that's the function, not the call. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nullschritt Posted July 25, 2013 Author Share Posted July 25, 2013 Thanks for all the help, I ended up having my child process write a value in the registry with it's PID, I chose to do it this way so that if the main process fails, and doesn't kill the child process, the next child process will be able to kill the previous child process, thanks for the ideas and suggestions as always though! Great community here, hopefully soon I'll be able to release my big project I've been working on in autoit, and share it here on the forums! Link to comment Share on other sites More sharing options...
JohnOne Posted July 25, 2013 Share Posted July 25, 2013 Never realized it was your own child process. I've had a similar problem in the past, I solved it like this in the child process main loop. While ProcessExists("MyParentProcess.exe") ;main loop WEnd Exit 0xdefea7 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Edano Posted July 25, 2013 Share Posted July 25, 2013 i usually call my parent script with cmdline params for child processes (all in one script). in this way all can write to the same local ini file. just to avoid registry spamming. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
kylomas Posted July 25, 2013 Share Posted July 25, 2013 @Edano - The process id is returned in the varible $ipid. In your example you are overlaying this with whatever is in the return array. The Help file could be clearer, but if you read the parameter descriptions it is pretty obvious what is happening. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted July 25, 2013 Share Posted July 25, 2013 Is it a help file issue or not? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted July 25, 2013 Share Posted July 25, 2013 @Edano - The process id is returned in the varible $ipid. In your example you are overlaying this with whatever is in the return array. The Help file could be clearer, but if you read the parameter descriptions it is pretty obvious what is happening. kylomas . i did not post an example, it is the genuine _WinAPI_GetWindowThreadProcessId() function from the _WinApi UDF i quoted. regard E. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted July 25, 2013 Share Posted July 25, 2013 (edited) Is it a help file issue or not? . yes the helpfile says Return Value Returns the Thread ID of the specified window . this is wrong. the Thread iD is returned ByRef. E. either adjust the helpfile or the function to return the PID as result. Edited July 25, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted July 26, 2013 Share Posted July 26, 2013 OK, please report to the help file thread so I don't forget to have a look. Thank you. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted July 26, 2013 Share Posted July 26, 2013 K [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now