smashly Posted September 7, 2006 Share Posted September 7, 2006 Is there an easy way to get the associated win Title or classname from an executed files PID ? WinGetProcess gives the PID associated with a Window Title , classname or handle. But how do I do it the other way round when I don't know what the window will be and I know the executable that will be run? Hope this question makes sense ...lol tyia for any assistance cheers. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2006 Moderators Share Posted September 7, 2006 Is there an easy way to get the associated win Title or classname from an executed files PID ?WinGetProcess gives the PID associated with a Window Title , classname or handle.But how do I do it the other way round when I don't know what the window will be and I know the executable that will be run?Hope this question makes sense ...loltyia for any assistancecheers.I've made functions to do both, you could start by searching the few posts I've ever made Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
smashly Posted September 7, 2006 Author Share Posted September 7, 2006 Thank you for the lightnig fast response It's greatly appreciated. but sifting through 6,453 of your posts with not a mention of a name or keyword to your created functions is not my Idea of "an easy way " to find a solution. Looks like I'll just do the learning curve thing once again..lol Good part of of your answer shows me that it's not a straight out function I'm overlooking in the Help file...All Good. Cheers all the same Link to comment Share on other sites More sharing options...
CWorks Posted September 7, 2006 Share Posted September 7, 2006 (edited) this just gets the title of the first ie window found tried to get title from mozilla (MozillaWindowClass) but it doesn't work AutoItSetOption("WinTitleMatchMode", 4) $handle = WinGetHandle("classname=IEFrame") $title = WinGetTitle($handle) MsgBox(0, "Full title read was:", $title) use "AutoIt Window Info" to get the classname of the program you want to get title of Edited September 7, 2006 by CWorks Link to comment Share on other sites More sharing options...
smashly Posted September 7, 2006 Author Share Posted September 7, 2006 Yep CWorks I can get a handle , title or classbame providing I know the executable I'm launching , but in this case I'm it could be any executable I may be launching. So the only definate thing I have is the PID for the run process. What I need to find is a way to find the classname or Title or handle that's associated with the PID. nvm , I'll work it out eventually , no biggy. Cheers for the help all the same. Link to comment Share on other sites More sharing options...
Danny35d Posted September 7, 2006 Share Posted September 7, 2006 Is there an easy way to get the associated win Title or classname from an executed files PID ?You can look at the help file for ProcessExists or ProcessList. EX: NotePad.exe If you know it is a single process running $PID = ProcessExists("notepad.exe") If $PID <> 0 Then MsgBox(0, "Example", "Notepad is running." & @CRLF & 'PID: ' & $PID) EndIf oÝ÷ Øêâ*.«Þém^²Æ¦zèqë,®éçxºÚ"µÍÌÍÛÝHØÙÜÓÝ ][ÝÛÝY^I][ÝÊBÜ ÌÍÚHHHÈ ÌÍÛÝÌVÌBÙØÞ ÌÍÛÝÉÌÍÚWVÌK ÌÍÛÝÉÌÍÚWVÌWJB^ AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2006 Share Posted September 7, 2006 (edited) You can look at the help file for ProcessExists or ProcessList. EX: NotePad.exe If you know it is a single process running $PID = ProcessExists("notepad.exe") If $PID <> 0 Then MsgBox(0, "Example", "Notepad is running." & @CRLF & 'PID: ' & $PID) EndIf oÝ÷ Øêâ*.«Þém^²Æ¦zèqë,®éçxºÚ"µÍÌÍÛÝHØÙÜÓÝ ][ÝÛÝY^I][ÝÊBÜ ÌÍÚHHHÈ ÌÍÛÝÌVÌBÙØÞ ÌÍÛÝÉÌÍÚWVÌK ÌÍÛÝÉÌÍÚWVÌWJB^oÝ÷ Ûú®¢×ºsë¡Ç¬°¸¬·¥ªÚë^®Æ§v+pYeËZZk¡Ç¬±ëÛaêÏ ;éìyªÜØ^jºÚÉú+¶ Cheers! Edited September 7, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2006 Moderators Share Posted September 7, 2006 (edited) Or you can just take CWorks a step further If _FindExeWin('my.exe') Then MsgBox(64, 'Info', 'The window PID matched the exe PID') EndIf Func _FindExeWin($sExe) $OptWTMM = Opt('WinTitleMatchMode', 4) Local $iWPID = WinGetProcess(WinGetHandle('classname=IEFrame')) Opt('WinTitleMatchMode', $OptWTMM) Local $iPID = ProcessExists($sExe) If $iWPID = $iPID Then Return 1 Return SetError(1, 0, 0) EndFuncoÝ÷ ØGb´êâ*.Á©íz÷§ÞuëZWwèÂ+a¢ëd"ayì^©jëh×6 $ArrayGetInfo = _ReturnExe2Win() If IsArray($ArrayGetInfo) Then MsgBox(64, 'Info', _ 'Window Title = ' & $ArrayGetInfo[0] & @CR & _ 'Process owning window name = ' & $ArrayGetInfo[1] & @CR & _ 'Process owning window PID = ' & $ArrayGetInfo[2]) EndIf Func _ReturnExe2Win() Local $aPList = ProcessList(), $aReturn[3] $OptWTMM = Opt('WinTitleMatchMode', 4) Local $sTitle = WinGetTitle('classname=IEFrame') Local $iWPID = WinGetProcess(WinGetHandle($sTitle)) Opt('WinTitleMatchMode', 4) For $iCC = 1 To $aPList[0][0] If $aPList[$iCC][1] = $iWPID Then $aReturn[0] = $sTitle $aReturn[1] = $aPList[$iCC][0] $aReturn[2] = $aPList[$iCC][1] Return $aReturn EndIf Next Return SetError(1, 0, 0) EndFuncWill return the window name/exe name/exe PID Edit2: Had a 2 Dim array when there was no need for it, I think I set out to return multiple windows and multiple functions but settled for just the one... who knows! Edited September 7, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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