implementing a java robot GUI function in Octave

5 visualizzazioni (ultimi 30 giorni)
Erdem Pulcu
Erdem Pulcu il 13 Mar 2017
Commentato: Rik il 4 Nov 2017
Dear Members,
I am not 100% sure if it is appropriate to ask a question about Octave/MATLAB differences here, but I have seen a few examples so here is my question.
I am trying to implement a function which was working perfectly fine in Matlab, and I am trying to implement the same in Octave. I am using a Windows 10 PC with Octave 4.2.1.
Initially when I was installing the Octave for the first time it complained that JRE were not installed, but I fixed this issue by installing and rebooting the program, so it doesn't flag this up anymore.
The Matlab code that I want to run on Octane is below, it should implement some mouse clicks on a GUI in an automated fashion.
robot = java.awt.Robot;
screenSizes = get(0, 'MonitorPositions');
store(loops,2)=zeros;
for i=1:5
%Mouse to upper left of primary monitor
robot.mouseMove(1, 1)
%Mouse to center of primary monitor
robot.mouseMove(mean(screenSizes(1,[1 3])),mean(screenSizes(1,[2 4])))
robot.mouseMove(270,125);
import java.awt.Robot;
import java.awt.event.*;
mouse = Robot;
%[rest of the code is not relevant so deleted for simplicity]
end
when I run the script Octave says in the command window
error: 'java' undefined near line bla bla bla
This GUI automation is very crucial thing for me, so I highly appreciate any recommendations (please give step by step details, as I am not so familiar of using Octave or Java, although fairly ok with Matlab)
Looking forward to hear from you
Erdem

Risposte (1)

Walter Roberson
Walter Roberson il 13 Mar 2017
Asking about Octave is not really appropriate here, but...
So I would expect
robot = javaobject("java.awt.Robot");
  2 Commenti
Erdem Pulcu
Erdem Pulcu il 13 Mar 2017
Thanks for the recommendation and sorry if it wasn't appropriate but didn't work anyway. Thank you once again
Rik
Rik il 4 Nov 2017
For future people looking at this: fixing the typo at least lets this line of code run.
robot = javaObject("java.awt.Robot");
Octave sorely lack a forum like this. It is especially annoying in case of issues that can be fixed with the java frame property. The absence of Octave Answers results in my Octave code being much less elegant and fast, even before execution.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by