Cannot get past 'System' function

1 vue (au cours des 30 derniers jours)
Sebastian Caceres
Sebastian Caceres le 19 Fév 2021
Commenté : Mario Malic le 19 Fév 2021
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)

Réponses (1)

Mario Malic
Mario Malic le 19 Fév 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 commentaires
Sebastian Caceres
Sebastian Caceres le 19 Fév 2021
Modifié(e) : Sebastian Caceres le 19 Fév 2021
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 le 19 Fév 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by