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 Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by