quagmire1973 Posted August 17, 2010 Posted August 17, 2010 I am writing a utility to work with various windows from multiple applications. The application will perform certain tasks on the active window but if the active window is a web browser, then I need to perform these tasks in a different fashion. So ultimately, I need to know if the active window is a browser, and then act accordingly. Now I know there are a ton of browsers out there, but for the purposes of my app, let's say we're only dealing with firefox.exe, iexplore.exe, and chrome.exe. I know we can detect windows and even tabs in a browser, but is there a way to map the window title to the PID/process that owns it? I can detect IE and Firefox by the text in the window because "Firefox" and "Internet Explorer" are always part of the window name. In Chrome they are not and other browsers may be the same. I'm looking to see if there is a way I can return the process ID of the active window, which I could then use to lookup the name of the process, and compare it to a browser list. Any ideas?
quagmire1973 Posted August 17, 2010 Author Posted August 17, 2010 Well I just now noticed that the actual window name in Chrome does have the browser name in it but I couldn't see it. I'd still like to know how to do the above though.
AdmiralAlkex Posted August 17, 2010 Posted August 17, 2010 (edited) Would it not make more sense to look at the window class? Exe-files aren't hard to rename. Ehh maybe not. Anyway, take a look at WinGetProcess() and _ProcessGetName(). The example for _ProcessGetName() is exactly what you're asking for. Edited August 17, 2010 by AdmiralAlkex .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
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