How can I programmatically control mouse motion and clicks with MATLAB?
Show older comments
I am creating a demo using MATLAB and I would like to programmatically move and click the mouse to demonstrate my application.
Accepted Answer
More Answers (1)
Unfortunately, this is one area that MATLAB is behind other alternatives, such as Python. If you know how to code in Python, you can easily do it by using the following command:
import win32api, win32con
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
click(10,10)
Categories
Find more on Data Type Identification in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!