java control of the mouse wheel

조회 수: 17 (최근 30일)
Chris Wilkening
Chris Wilkening 2018년 1월 21일
답변: Chris Wilkening 2018년 1월 21일
I am trying to programmatically mouse wheel up/down within a window. I can move and click the the mouse fine but I cant scroll up or down.
Within the Matlab command window I entered
>> rand(10000, 1) % make something to scroll up to
Then after that prints
import java.awt.Robot;
import java.awt.event.*;
mouse = Robot;
mouse.mouseWheel(-100); % negative is up
I have tried +100 and other larger and smaller values - all no luck.
I have read How can I programmatically control mouse motion and clicks with MATLAB? and it is great for moving the mouse and clicking but it does not help with scrolling.

답변 (1개)

Chris Wilkening
Chris Wilkening 2018년 1월 21일
The below code works when the program first clicks into a Chrome window - it does not seem to work in the Command Window. Or the Command Window is resetting back to the bottom after the scroll, is hard to tell.
import java.awt.Robot;
mouse = Robot();
mouse.mouseWheel(1);

카테고리

Help CenterFile Exchange에서 Robotics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by