Filter löschen
Filter löschen

Need to simulate a keypress in a matlab script

19 Ansichten (letzte 30 Tage)
Jonathan Broyles
Jonathan Broyles am 29 Nov. 2023
Kommentiert: Jonathan Broyles am 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by