none
Click on a particular image on a screen RRS feed

  • Question

  • Is there a way to use VBA to click on a particular image on the screen?  I am trying to automate some mouse clicks on a particular system, but the mouse clicks depend on where a particular image is on the screen.

    Thanks,

    Matt


    • Edited by matwenty8 Friday, November 18, 2016 10:52 PM
    Friday, November 18, 2016 10:52 PM

All replies

  • Do you want to do this for a non-Office app image or for something like a Powerpoint or Excel image?
    Friday, November 18, 2016 11:38 PM
  • I would like to do this for a non-Office app image.  Do you think this is possible?
    Monday, November 21, 2016 5:27 PM
  • It may be possible.  I did something like this many years ago.  I used a screen capture program (Minicap.exe, free) to capture a screen image and used ImageMajick (free) to search for the sub-image on the image (used compare command).  It returns x,y coordinates of the sub-image.  You can use Win32 commands to move the mouse and click.  I did this in VBA by calling command line commands.  It took a few weeks to work out the details.  You can set an accuracy level for the comparison. 

    Public Declare Function SetCursorPos& Lib "User32" (ByVal x As Long, ByVal y As Long)
    
    Public Declare Function mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As Integer) As Integer


    Monday, November 21, 2016 6:07 PM
  • BTW, what program has the image.  If it is a browser then there are much easier solutions.
    Monday, November 21, 2016 6:19 PM