Jump to content

Returning xy co-ordinates of window on mouse click only in specific application.


Recommended Posts

I am new to AutoIT (though familiar with VBA coding). 

My requirement is this:

When I press the left mouse button, the code should check whether the window in which it is clicked is of a specific application e.g. Notepad. If yes, it should return the x y coordinates of the Screen of the point of mouse click. If the application is not Notepad, nothing should happen on mouse-click. 

Actual code for the above alongwith with pointers to further reading for understanding various options would be much appreciated. 

Thanks in advance.

Link to comment
Share on other sites

  • Moderators
3 minutes ago, Rajendra said:

My requirement is this: ...

That's awesome. However, this forum is not a restaurant, where you put in an order and someone serves up ready made code. This forum is dedicated to helping people with their own scripts, so - what have you tried on your own?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks, Logan, for enlightening/reminding me about the fact that this forum is not a restaurant for fulfilling Code orders. 

By "My requirement is this", I only meant to say, "I want to do this" and did not mean to order. 

As I am a newbie to AutoIT, I thought that sample code with pointers for further reading would accelerate my learning process and that's what I requested. As I have stated in my original post, I am not new to programming and am fairly proficient in VBA. I wanted to evaluate, based on the AutoIT code and the pointers, if provided by someone, as to the learning curve involved and decide accordingly. 

(In the good old days of the Internet, there used to be an acronym "RTFM" used as a response to naive requests like mine. (RTFM =Read the Fine mamual. Some used to say that the 'F' stood for something more profane)) 

Please forgive me for making this post so verbose; English is not my native language and I have difficulty in being crisp and precise. 

Link to comment
Share on other sites

1 hour ago, FrancescoDiMuro said:

Hi @Rajendra, and welcome to the AutoIt forums :welcome:

Sorry if I ask, but why do you need to obtain the coordinates of a point clicked in an application?

If you want ti automate an application, there are several (better) ways to do it :)

The complete details are as below. Please study and let me know if there is a better approach.

I take videos of social events like family functions (as the mood gets captured better that way then than when I capture photos) . Then, I play the video frame by frame and capture the images which I want to process further. As the video is taken from a distance, I want to crop the images as the target in the picture is a fraction of the frame/image. As the target is more or less at a certain distance with small variations in the position in the frame, the dimensions of the cropped image remain constant. Using arithmetic, I have computed the x,y, width, height dimensions need for cropping. I want to crop on the centre of the target in the bigger image and then recompute the revised x,y, width,height dimensions of the crop. T

Link to comment
Share on other sites

Just now, Rajendra said:

The complete details are as below. Please review and let me know if there is a better approach.

I take videos of social events like family functions (as the mood gets captured better that way then than when I capture photos) . Then, I play the video frame by frame and capture the images which I want to process further. As the video is taken from a distance, I want to crop the images as the target in the picture is a fraction of the frame/image. This will reduce the size and will improve the focus.  As the target is more or less at a certain distance with small variations in the position in the frame, the dimensions of the cropped image remain constant although the target position changes.  Using arithmetic, I have computed the x,y, width, height dimensions needed for cropping. I want to crop on the centre of the target in the bigger image and then recompute the revised x,y, width,height dimensions of the crop. To do this, I need to find the x,y coordinates of the centre of the target. I do this in the IrfanView application. Hence, I want to get the x,y co-ordinates by clicking at that point and capture the image name and the x,y, coordinates in a text file (notepad), which will then be used to generate a command line statement for cropping the file using the image editor application (iIrfanView).  Maybe, there is a much shorter process for doing this as I am not aware of the full potential of AutoIT. Would love to hear about the same. Thanks.

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...