Cannot get past 'System' function
3 ビュー (過去 30 日間)
古いコメントを表示
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)
0 件のコメント
回答 (1 件)
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 件のコメント
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 Exchange で Dialog Boxes についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!