필터 지우기
필터 지우기

Need to simulate a keypress in a matlab script

조회 수: 35 (최근 30일)
Jonathan Broyles
Jonathan Broyles 2023년 11월 29일
댓글: Jonathan Broyles 2023년 11월 29일
%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

채택된 답변

Walter Roberson
Walter Roberson 2023년 11월 29일
  댓글 수: 1
Jonathan Broyles
Jonathan Broyles 2023년 11월 29일
Thank you for the quick reply and it works perfectly and was clean to implement.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by