2

Is there any way to get the location (x,y coordinates or similar) of the icon for the Recycling Bin on the Desktop?

Thanks

2

Code updated.

You can use AutoHotkey for it. You need Imagesearch command to do it. Here is complite code that does what you need:

CoordMode, Pixel, Screen
ImageSearch, varX, varY, 0, 0, 1360, 768, rb.bmp
MsgBox, Recycle Bin coordinates are x=%varX%, y=%varY% .

In this code replace 1360, 768 with your monitor screen resolution.

Put all code in notepad and store it as anyfilename.ahk .

rb.bmp is the image of Recycle Bin icon. To make it, make image as redline in this picture below. So your image should be the part of Recycle Bin icon that is on my picture as red line. Not make rb.bmp as my image, it should include only red square part of my image! Put rb.bmp in the folder where anyfilename.ahk is.

enter image description here

So rb.bmp should look like this:

enter image description here

Download new version of AutoHotkey from http://ahkscript.org/ (current version) , not from autohotkey.com (outdated version!) and install it.

After installation of AutoHotkey double click on anyfilename.ahk . You will get coordinates of the left upper corner of rb.bmp (green circle in my first picture) in message box.

AutoHotkey also has converter which allows you to convert .ahk file to .exe file if necessary.

Second version

Works with full and empty Recycle Bin:

CoordMode, Pixel, Screen
Loop
{
    ImageSearch, varX, varY, 0, 0, 1360, 768, rb1.bmp
    if(varX!="")
    {
        MsgBox, Full Recycle Bin coordinates are x=%varX%, y=%varY%
    }
    varX:=""
    varY:=""

    ImageSearch, varX, varY, 0, 0, 1360, 768, rb2.bmp
    if(varX!="")
    {
        MsgBox, Empty Recycle Bin coordinates are x=%varX%, y=%varY% 
    }
    varX:=""
    varY:=""

    Sleep, 1000
    break
}

rb1.bmp is for full Recycle Bin icon.

rb1.bmp is for empty Recycle Bin icon.

I have also putted sleep command. 1000 is here value in milliseconds (1sec=1000 milliseconds). With that command it will wait 1000 milliseconds to check Recycle Bin again. You can give it any value. Also you can remove that command at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.