How to check which window is focused

15 pts.
Tags:
Focus
Visual Basic
Visual Basic 2008
How can I check if the focus is on a specific window(program). For example: My program should do something only if the focus is on notepad. If the focus is on something else it should do nothing. So.. I have the PID and the image name of the progam to check... but i don't know how to validate it..

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you have the name and PID of the program, I would think that you could monitor the process in Task Manager to see if there is something kicking in when you open Notepad….unless I missed something in your question?

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • SpacecowBoy99
    I'm thinking more aboute a pointer or something like that, that points to the focused (or active) application so that I can comper the PID that I have with the PID of the focused application. If FocusedApp.PID = MyPApp.PID Than ' Do something ' .... End If I'm not sure what is possible, cause I'm new to Visaul Basic and just starting to learn
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following