Azzera filtri
Azzera filtri

Need to simulate a keypress in a matlab script

13 visualizzazioni (ultimi 30 giorni)
%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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by