Link to home
Start Free TrialLog in
Avatar of ART_Mac03
ART_Mac03Flag for United States of America

asked on

vbscript: how can I use the process id to get a windows handle

I can capture all the process ids for a client under test, but I currently at a loss on how to convert those ids into window handles.

Process Id Code
Function ProcessId
   'capture the hwnd  from all windows with a certain caption
set objService = getobject("winmgmts:")
		For each Process in objService.InstancesOf("Win32_process")   
			If  Process.Name = "FronTIER.exe" Then
						ret = msgbox(Process.processid, vbOkCancel)
						
If ret = vbCancel Then
							ExitTest micWarning
						End If
			End If
		
		Next

End Function

Open in new window

Avatar of Govvy
Govvy
Flag of United States of America image

From command prompt:

>tasklist | findstr <PID>
ASKER CERTIFIED SOLUTION
Avatar of Darrell Porter
Darrell Porter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ART_Mac03

ASKER

let me try this. I do not know I could not think of this simple solution.

I need to my code simple due to my users; your solution can be what they would like.
typo: I do not know why I did not think of this solution.
The solution was helpful especially since the info. displayed to my user community was direct and non-complex.
I eventually found a different way to solve my org. problem with using Process IDs to determine Window handles. I am using the test tool QTP to capture the windows object data based on the Swfname of the application or the object name of a feature in the app.  I pass the object name based on the process ID/name of the process.
thanks for both solutions.