Cannot get past 'System' function

조회 수: 2 (최근 30일)
Sebastian Caceres
Sebastian Caceres 2021년 2월 19일
댓글: Mario Malic 2021년 2월 19일
Hello! The system function below will open the Zebra Setup utility window, from which I can manually select and print labels. the last four lines of the code are my the beginnings of my attemps to automate the process by having my mouse move to and click the 'open communication with printer' button. However, these lines will not run after the system function even though they work independently.
To fix this I run ctrl+C in the command window but that terminated the code and closes the Zebra window. How can I have code continue after opening the application, aka have the mouse move, without terminating the script?
To try this, please replace the system file path with an application you have on your device (app > properties > shortcut > target)
and adjust the mouse.mouseMove values to something on the screen to be left-clicked.
import java.awt.Robot; %imports ability to move the mouse
import java.awt.event.*; %imports ability to click the mouse
mouse = Robot;
screenSize = get(0, 'screensize'); %Calibrate according to these values
%Opens Zebra Setup Utilities
system("C:\Users\scaceres\Desktop\ZebraPrinter\Zebra Technologies\Zebra Setup Utilities\App\PrnUtils.exe")
disp('next step')
mouse.mouseMove(1150,690) %Open Communication with Printer
mouse.mousePress(InputEvent.BUTTON2_MASK);
mouse.mouseRelease(InputEvent.BUTTON2_MASK)

답변 (1개)

Mario Malic
Mario Malic 2021년 2월 19일
Hi,
You do it by adding ampersand '&' at the end of your system command.
system("C:\Users\scaceres\Desktop\ZebraPrinter\Zebra Technologies\Zebra Setup Utilities\App\PrnUtils.exe&")
pause(3); % Wait for the program window to load
  댓글 수: 2
Sebastian Caceres
Sebastian Caceres 2021년 2월 19일
편집: Sebastian Caceres 2021년 2월 19일
Hi Mario!
After I added the ampersand to the system command, my computer is now opening up the Zebra Setup Utility AND the terminal window. However, the cursor is still not moving, is there something else I should add? Thanks!
Sebastian Caceres
Mario Malic
Mario Malic 2021년 2월 19일
Hmm, that's weird that command window opens, usually it doesn't happen. Can you check the link from other question, use those commands and check if command window opens as well?
I haven't used java.awt.Robot before, but these mouse commands work on my PC.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by