Borrar filtros
Borrar filtros

Need to simulate a keypress in a matlab script

13 visualizaciones (últimos 30 días)
Jonathan Broyles
Jonathan Broyles el 29 de Nov. de 2023
Comentada: Jonathan Broyles el 29 de Nov. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by