Effacer les filtres
Effacer les filtres

Need to simulate a keypress in a matlab script

13 vues (au cours des 30 derniers jours)
Jonathan Broyles
Jonathan Broyles le 29 Nov 2023
%Need to be able to simulate a keypress in GUI matlab script
%Below is the simplified code segment for how keypress are collected and processed. Later in a diffenent function I need to be able remotely press the "space" key to call "pauseCallback(this);". In C, I would use ungetc(), and I did try a dos command but it failed becuase it opens in a different shell than matlab. Also, if you simplay make the call in the later function, which will need to repeated, it will eventually fail from stack overflow. I looked at everything I could find, but to no avail, any ideas here would be greatly appreciated, Thank you.
%Add Keyboard Processor - Hot Key Commands entered from keyboard
h_keyboard = this.FigureHandle;
set(h_keyboard,'KeyPressFcn',@keyproc);
function keyproc(src,event)
disp(event.Key);
if event.Key == "space" %% Stop/Start Audio Playback
pauseCallback(this);
end
end

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Nov 2023
  1 commentaire
Jonathan Broyles
Jonathan Broyles le 29 Nov 2023
Thank you for the quick reply and it works perfectly and was clean to implement.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by