Identify active window

I need to be able to identify which program is being used by the user.
Getting the active window is easy with GetForegroundWindow but, how do
I query that window to find out which program it is? What I mean is,
how do I know it is GIMP and not Word? Or IE and not Netscape?

If there is no general solution, I need to at least be able to identify
Word and IE.

Thank you all.

0
the44secs (141)
7/27/2006 8:59:23 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
761 Views

Similar Articles

[PageSpeed] 47

I am wondering where you calling GetForgroundWindow and when you
calling?after getting HWND  a lottoff ways to  identify , which
program(check caption etc).

Alexander wrote:
> I need to be able to identify which program is being used by the user.
> Getting the active window is easy with GetForegroundWindow but, how do
> I query that window to find out which program it is? What I mean is,
> how do I know it is GIMP and not Word? Or IE and not Netscape?
>
> If there is no general solution, I need to at least be able to identify
> Word and IE.
> 
> Thank you all.

0
zidansoft (30)
7/27/2006 9:29:34 AM
Thanks for the reply.


> I am wondering where you calling GetForgroundWindow and when you
> calling?


This is for an app running in the background that collects usage stats.
I want to know who uses what and for how long to decide which licenses
to renew, etc.


> after getting HWND  a lottoff ways to  identify , which
> program(check caption etc).


It doesn't always work. Which are the other methods?

0
the44secs (141)
7/27/2006 10:22:41 AM
"Alexander" <the44secs@yahoo.com> wrote in message 
news:1153990763.397479.80230@i42g2000cwa.googlegroups.com...
>I need to be able to identify which program is being used by the user.
> Getting the active window is easy with GetForegroundWindow but, how do
> I query that window to find out which program it is? What I mean is,
> how do I know it is GIMP and not Word? Or IE and not Netscape?
>

Use GetWindowThreadProcessId() to get the process id of the foreground 
window.  Then use  CreateToolhelp32Snapshot() to iterate running processes, 
and compare each to the process id.  When it matches, you will have the 
process name.  Search the process name for IEXPLORE, NETSCAPE, etc.

-- David



0
dc2983 (3206)
7/27/2006 2:38:16 PM
Thank you for the reply, David.

I have implemented the solution you have suggested. The information I
have access to with the structure PROCESSENTRY32 contains the filename
of the executable file for the process.

Am I correct to assume that is what you meant by "process name"?
Apologies if my question is, well, somewhat dumb.

I have another question, if I may tax your patience. Once I have the
handle to the process, is there a way to determine if the particular
application supports automation interfaces?

Thanks again.

0
the44secs (141)
7/27/2006 11:31:43 PM
Problem solved.

0
the44secs (141)
7/29/2006 8:43:31 AM
Reply:

Similar Artilces:

why it cann't work?(about subclass window)
void CXXXXTreeView::PreSubclassWindow() { // TODO: Add your specialized code here and/or call the base class CTreeView::PreSubclassWindow(); if(m_ctlDragTreeCtrl.GetSafeHwnd() ==NULL){ //VERIFY(m_ctlDragTreeCtrl.SubclassWindow(GetTreeCtrl().UnsubclassWindow())) ; //VERIFY(m_ctlDragTreeCtrl.SubclassWindow(GetTreeCtrl().GetSafeHwnd())); } } frist comment will cause assert in CTreeView::CreateEx(...) ,second comment direct cause assert,how i should subclass a treectrl in the treeview? "leighsword" <leighsword@163.net> wrote in message news:ubdD0bhZDHA.2136@TK2MSFTNGP...

Move Active Window
I need to write a program that moves the active window after every 20 seconds. I believe there must be some api function for that but dont know which one. Can any one help. In most case the active window will be VB6 IDE itself so if any active window is not easy is it easy to write a code that moves the VB6 IDE after every twenty seconds?? Don't ask why I want to do it, I just need to do it!! Thanks On Sat, 5 Dec 2009 18:05:15 +0500, "VB6Pro" <no_more_nonsense@myemail.com> wrote: >I need to write a program that moves the active window after every 20...

Active Directory not Createing Email Address
I am running Exchange 2000 sp3. All of a suddern when I create a new user in Active Directory, I am creating a mailbox, but the user is not getting an email address. This problem has just started happening, previously email addresses were being created. I am getting no errors in the event log. Can anyone tell me how I can begin to troubleshoot this issue. -- semdvm01 ------------------------------------------------------------------------ Posted via http://www.webservertalk.com ------------------------------------------------------------------------ View this thread: http://www.webserv...

Activity workflow in CRM 3.0
Is it possible to create a workflow rule to email me when a task activity becomes older than 2 weeks ? I only want alerts for tasks regarding cases with a subject "Claims" Thanks Marc ...

Recordsets different with Windows Vista?
I have a new computer running Vista. I tried to use my database with it and have come across several problems. The one I'm working on now is a recordset. The following code creates links to documents related to my contacts. Public Sub Make_Link(docname As String, strComment As String, strDocType As String) 'Put a link to the file in the SubLinks form Dim rstLinks Set rstLinks = CurrentDb.OpenRecordset("Links") rstLinks.AddNew rstLinks.ContactID = Forms!Master!ContactID rstLinks.LinkDate = Now rstLinks.Link = "#" &...

Journal Entry doesn't show up under activities
I had a contact opened up and clicked file>new>journal entry and saved/closed it. When I go back to that contact and click on activities tab and journal drop down it doesn't show anything. The only way I'm able to view it is by navigating to it on the file tree. P.S. Using outlook 2002 ...

What is the correspondence to SqlDataSource in windows
Hello! The SqlDataSource Class is a part of System.Web Assembly and used by data-bound controls in ASP.NET Can somebody tell me what is the nearest correspondence to SqlDataSource in windows form //Tony "Tony Johansson" <johansson.andersson@telia.com> wrote in news:fTbWm.13647$U5.204106@newsb.telia.net: > The SqlDataSource Class is a part of System.Web Assembly and used by > data-bound controls in ASP.NET > > Can somebody tell me what is the nearest correspondence to > SqlDataSource in windows > form SqlDataSource is a wrapper ...

Error sending messages on Windows Mail
Have NOT been able to send emails from my Windows Mail account. Error message is as follows -- Unknown error has occurred - Server: smtpauth.earthlink.net Protocol: SMTP" Server response - '503STARTTLS command used when not advertised Port: 587 Secure (SSL): Yes Server Error #0x800CCC65 (this was for an outgoing message directed to a third party) I tried to send a message to my own email account and the Error Message was exactly the same, EXCEPT that the final line of the Error Message said - Server Error #0x800CCC90 I get error message numberox800ccc19 I wond...

Activate Exchange 2003 Trial
If we purchase exchange 2003 can we use it to activate our exchange 2003 trial that's currently installed and setup? Or do we have to uninstall the trial, then install the registered version of exchange 2003? Thanks It is my understanding that you have to unistall the trial version due to licensing rules that MS makes, then install the full version of MS Exchange 2003 "tomas789" wrote: > If we purchase exchange 2003 can we use it to activate our exchange 2003 > trial that's currently installed and setup? Or do we have to uninstall the > trial, then instal...

Messenger no longer opens message window
When a Messenger contact is offline, I right click and select Send Email. In the past, a new message window would open for me to write the message. Outlook opens if it was closed, but the new message window doesn't; if Outlook was already opened, its icon in the system tray blinks, but a new message window does not open. I should point out that this started happening after I downloaded Mozilla Thunderbird, another mail program, and used it for a few days. I have since uninstalled it and returned to Outlook. I am having another, likely related problem. I have downloaded Mozilla Firefox br...

Window activation woes
Hi, I want to prevent multiple instances of my application running at the same time, which I've done, however when a second instance is started I want it to activate the main window of the first instance. This I have sort of done. When the second instance detects it isn't the first instance it uses BroadcastSystemMessage with a registered window message to tell the first instance to bring it's main window to the top. Below is the code I'm using for window activation: LRESULT CMainFrame::OnActivateInstance(WPARAM wParam, LPARAM lParam) { if (IsIconic()) ShowWindow(S...

WLM, Windows Live Contacts, and Multiple Accounts
I have 2 Hotmail accounts configuring in WLM Desktop. When I select Go==>Contacts, the Windows Live Contacts dialog is shown, but only for _one_ of my email accounts. I can't figure out how to show the contacts related to the other account. Does anyone know how? Thanks, P. Upper right corner where your live acct ID is shown.. "sign in with a different ID". Choose other ID. "Oceanclub" <Oceanclub@discussions.microsoft.com> wrote in message news:95D4DAD4-3307-4FA7-8BE6-A73C4DE198D4@microsoft.com... > I have 2 Hotmail accounts configuring ...

Two "versions" show up in window tab? file:1 file:2
I have a coworker who when he opens a file, and looks under the windo tab, two files of the same name show up separated by colon and number. e.g. file:1 and file:2 by switching from "version" 1 and 2, file is identical in both window and seems to be embedded in properties. He says he accidentaly hit some keys and it did this and I can't seem to be able to recreate this. Does anyone know what this function is? Thank -- mpoirier2 ----------------------------------------------------------------------- mpoirier23's Profile: http://www.excelforum.com/member.php?action=get...

Importing Bank Activity posts all Trans to one vendor
Everytime I import my checking account info all my transactions appear as Wal-Mart transactions although the Memo field is correctly listing the correct vendor. Anyway to correct this or must a manually change all my transactions, which almost defeats the purpose of importing my banking transactions. Thanks. In microsoft.public.money, Fran wrote: >Everytime I import my checking account info all my >transactions appear as Wal-Mart transactions although the >Memo field is correctly listing the correct vendor. > >Anyway to correct this or must a manually change all my &g...

[ANN] 64-bit Radiance HDR decoder for Windows 7, Windows Vista and Windows XP
Geneva, Switzerland, August 24, 2010: www.fastpictureviewer.com has released a high quality Radiance HDR decoder for Windows 7, Windows Vista, Windows XP SP3 and Windows XP 64. The codec comes in both 32-bit and 64-bit flavor and extends Windows Explorer by enabling thumbnail views of Radiance HDR files in the popular 32bpp RLE RGBE format. Additionally, users of Windows 7 and Windows Vista can open files for full-size viewing using the system's built-in Windows Photo Viewer, WIndows Photo Gallery and Windows Media Center 7. The codec also extends Windows Imaging Component -...

windows media player 12 crashes on starting up
This is a multi-part message in MIME format. ------=_NextPart_000_000A_01CA7C36.9B9609A0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit i have windows 7 ( verified genuine ) i recently replaced the motherboard and cpu to a better spec but the ONLY thing that doesnt work following upgrading is media player 12 i start it up and get a error message followed by the usual search for problem resolution but as yet i have heard NOTHING to resolve the issue it happens EVERYTIME i start it ...

How to have a form type window in MFC Single Document view window
Hi I want to place buttons and textboxes on a MFC single document view app. How can I do this if I generate a MFC single document view application using wizard? Angus You shoud use a CFormView in a SDI app(MDI is also fine). A CFormview will take a dialog template as input. You can place all the controls you want on the dialog and associate it with CFormView. -- Ajay "Angus" <anguscomber@gmail.com> wrote in message news:debef4be-4226-46e4-af31-f5ffeeb9cf21@r66g2000hsg.googlegroups.com... > Hi > > I want to place buttons and textboxes on a MFC single document ...

windows service and virtual driver
I have learned OpenSCManager can install and load a sys file without a device and Pnp hardware ID, does this way differ from a virtual driver ? I can add kernel mode IO control and kernel mode access function in this driver. Is there any reference about WDM virtual device driver ? I would like to learn how to implement USB2COM or other interface but I do not know where can find some good document or sample , and how a app can create a virtual device node . Thank for your kind teaching . The Service Control Manager interface can install a legacy device driver this is one...

My Tasks showing 2 Views in the window
After using site actions to change the MY TASKS display to show as hours rather than days, users are reporting having 2 "views" appearing in the My Tasks window. The heading even shows "My Tasks (2)". This does not occur on my or other admin's views. But, the other users all see this double view in the window. Any ideas how to address this? On Mar 31, 11:59=A0am, Bonnie <Bon...@discussions.microsoft.com> wrote: > After using site actions to change the MY TASKS display to show as hours > rather than days, users are reporting having 2 "v...

Allow us to change default view in Account Activity History.
In the current version of CRM (3.0) the default views of the History View cannot be changed. I would like to be able to set it to "All" not just the most recent. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Comm...

Windows Update Error Code 80010108
Hi all, I have been trying to update my computer (Windows 7 64 bit) and its been two days since I've been trying to update and it just does not update! I get the error code 80010108 and I have no idea whats going on. If anyone has any clue or if anyone is experiencing this as well please let me know! Thanks for your help! A Google search on 80010108 resulted in pages of things to check. "JoJo" <JoJo@discussions.microsoft.com> wrote in message news:9DE0AA5F-2C7E-4789-A119-34070F83F836@microsoft.com... > Hi all, I have been trying to update my computer (...

Strange Active-X control problem
I was experimenting with the Active-X control "Calendar Control" and everything seemed to be fine on my Win2K development system. I tried executing the program on my WinXP desktop system and as soon as I invoked the dialog that includes the control I got the dreaded "XXX MFC Application has encountered a problem and needs to close down..." message. Okay, strike one. Perhaps it means that the control isn't registered on that system and I'd appreciate either confirmation or correction on this. BUT ... Then I also tried executing the program on my Win98SE system an...

Windows Mail Error
Sorry if this has been asked before. When I try to open a previously read or unread email, all of a sudden I get the following message: "There was an error opening this message. An error has occurred." Any help, please. Usually, that means that the message has been deleted or corrupted. Sometimes I've found messages like that in the Recovered Items folder. My experience... This same behavior occurred frequently when I closed/copied/moved messages within Quick View. Upon counsel of wiser more experienced folks, I rid myself of Quick Views and now I open (...

Windows 7 plug and play printer install
I just finished updating a printer driver for Windows 7. It installs fine if I "add printer" manually, but when I try the Plug And Play, Windows 7 pops up a balloon that says "new hardware found", and tells me it is looking for the driver for the device, and then it says it can't find the driver. The hardware wizard never prompts me for the location of the driver files. As far as I can tell, it only looks at the Windows update site for the driver. How do I get Windows 7 to prompt me to specify where the driver INF and files are located? Where are th...

how do I change from arabic to english in microsoft windows
Can you help? I can't find out where and how to change from arabic to english in microsoft word. Do you mean you want Word's menus and labels and such to appear in English instead of Arabic, or do you mean that you want to type English text and not Arabic text, or do you mean that you want your computer to operate with an English instead of Arabic interface? On Dec 24, 6:05=A0am, technophob <technop...@discussions.microsoft.com> wrote: > Can you help? =A0I can't find out where and how to change from arabic to > english in microsoft word. ...