How to programmatically press a key?
21 次查看(过去 30 天)
显示 更早的评论
How can I programmatically press a key in Matlab? I click outside of the Matlab environment by the java.awt.Robot command, but after that I would like to press some keys (e.g. type "Hello"). I tried the keyPress(KeyEvent.VK_H) command found online, but that does not seem to work. Any suggestions?
This is the code I tried:
import java.awt.Robot;
import java.awt.event.*;
robot = Robot();
robot.mouseMove(1100,54);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.keyPress(KeyEvent.VK_V);
2 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!