Cannot get past 'System' function
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Mario Malic
on 19 Feb 2021
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 Comments
Mario Malic
on 19 Feb 2021
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.
See Also
Categories
Find more on Dialog Boxes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!