Click here to Skip to main content
13,249,087 members (43,872 online)

Cursor position relative to active program window

kalora asked:

Open original thread

I am writing an application in VB express 2010. I need to be able to bring focus to a running application window, which is NOT part of the program and get the cursor co-ordinates relative and within the bounds of that window only. Both the running program and the application window need to both be visible.

For instance I might have the VB program running and then open Windows Media Player. I should then be able to get the mouse coordinates of say the pause button relative to the player, so wherever the player is on the screen, these coordinates will always be the same. The player is just an example, it could be ANY active program window - I would need to be able to choose the active window and set focus to that.

I can use cursor.position.(X/Y) to get the coordinates of the cursor anywhere on the screen but I need it relative to the active program window.

Many thanks
Tags: VB, VB10.0


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100