How to close app on Windows


This is my very first post to the UI Vision forums. I’m trying something more basic with the Windows Calculator application based on one of your examples.

I’m able to open and close the gnome-calculator application on Linux Mint, but on Windows 10 I’m able to open the calculator application, but not close it.

I have tried OCR with XClick and XClick relative by setting the precision to 0.6.

Then I tried type and XType in the following combinations as shown in the screen shot, but none of these work!

However, when I use the Alt+F4 combination manually, I’m able to close the calculator.

Any suggestions on why this doesn’t work through the macro?



I think can be a problem of focus, you need to have focus on calc before you can close it.

I suggest to use Xclick on calc image, and after Xtype with Alt+F4 or X image to close software.

In your code i see some errors, check Xtype commands must be ${KEY_ALT+KEY_F4} read the part modifier keys for ALT key

Here an example to use modifier keys
Typical usage: XType | text here {KEY_CTRL+KEY_V} more text here {KEY_ENTER}

I’m pursuing the same line of thinking. But here is my issue. When I debug the code, the automation is able to find the image.Although it finds the wrong “x” I was thinking if I could click on it and get the focus back to the Calculator window, I could then use the combination keys. But the problem is that when the Macro runs, it isn’t clicking on the x that it sees during debug. :frowning:

thanks for pointing out the issue with the key press code. :slight_smile:


A screencast would be helpful to see what is actually happening on your machine…

To get the focus, I would use a larger image, they are usually found easier. Here is what I would use:

XClick | image

Small images like “x” icon or “5” button are tricky and can be confused with other small images that look similar. Some general tips for small images:

  • Instead of using a small image like image make it a bigger image to press “5”:

<= more more stable image to find and press “5”.

  • Or use XClickRelative where you can pick a good anchor image:


Hi, I was able to get it to work! :smiley: The code is below. I tested this on dual screens, my laptop and the larger monitor and it works without issues. I think the gray-black contrast of the images is a problem. In Mint Linux it was really easy because the calc icon has 3 colors!


You are correct that I could use a larger image. But the problem is that the mode “Standard” can change. If I switch to mode “Scientific”, and close the calculator, the automation will fail because next time the calculator will open in Scientific mode and the image scan will fail! I was trying to use something that is not bound to change on the UI.

My corrected code is below. Pretty straight forward 3x lines in Green and no image-OCR required! :smiley:

Thanks for the quick responses! Truly appreciated!
Please try this and if it works on your end, please mark as solution.


I’m surprised that the OCR was not able to find this image :worried:


I’m hoping someone tries out this case and lets me know if they’ve had better luck. I have tried the following images including this last one with XClickRelative. The automation isn’t able to find such a grey-black contrasting image even with 0.4 confidence level!

Either I’m doing something wrong, or the OCR has issues. Other images I have tried with XClick are:




You mention OCR, but this has nothing to do with the OCR features screen scraping features, or? (OCR is not good at single numbers)

Your green/pink screen looks good. A screen video of you testing it would be helpful to see what is going on. It should work fine.

Hi @ulrich

Sorry it’s a bad habit of mine. Each time I try to scrape numbers or text of the screen, my brain makes a bad association!

I will try to get a recording out tomorrow. In the meantime, I will try this on my personal laptop and see if it works better there.