Sign in to follow this  
Followers 0
dragan

[SOLVED] get win handle from pid using wmi?

8 posts in this topic

#1 ·  Posted (edited)

I'm curious, is it possible to get window handle with pid using wmi? I already know the wingetproc and winapi functions to do so, I'm only curious if wmi is powerful enough to do so as well.

Edited by dragan

Share this post


Link to post
Share on other sites



I'm not very familiar with AutoIt and the wmi thing, but one thing I do know and like to stress is the reliability of using windows services and other preinstalled applicatons, as in if lots of people are going to use it, sometimes it fails under certain conditions, just like InetRead() in the case that a user uninstalled IE, I've had headaches with that :P

If you'd like, take my advice and use the windows API to do these things like what you just said :)

It's not nessasary to use wmi for something you should be using windows oem dlls to do.

Share this post


Link to post
Share on other sites

Also, if I'm right, WMI is intended for things like scripting languages that do not support things like calling dll functions the way autoit and other languages can, so I personally think it's better to stay away from it entirely unless developing an appliation that will do network things, like using UPnP to foward a port to your app to act as a server.

Share this post


Link to post
Share on other sites

I second FlutterShy,

WMI isn't the best tool to do what you want. Search the forum for Pid and handle and you will some ready made solutions.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you for your replies.

Little intro to my project:

I'm making a server for my PC (Autoit based) that will communicate with my Android device (I'm also making android client), and I would like to get a list of all processes and PIDs and win handles sent to my Android device, however, I discovered that listing these things using WinGetProcess and using GetWindowThreadProcessId from user32.dll will result in failure if I have one online game running in the background. So its not usable all the time. Game is protected by GameGuard - maybe that's the problem, however those functions work fine without this game running.

The idea is to click the listed process or PID in Android device (sent by autoit server) and to set that PID's window as the active one, but I can't do that if the functions above gives me failure, that's why I'm asking about WMI.

Share this post


Link to post
Share on other sites

Hi,

Seems like WMI does not handle the windows, so you can not get the process from a window.

However you can get the process list.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Somehow I overlooked and WinApi_EnumProcessWindows func, it seems to work just fine. Thank you all.

Share this post


Link to post
Share on other sites

Glad you could solve your problem :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0