KeyInject

버전 1.1.0.0 (4.22 KB) 작성자: Phillip
Send key strokes to any window from within Matlab
다운로드 수: 1.4K
업데이트 날짜: 2013/1/31

라이선스 보기

Send key strokes to a named Window. Alt, Ctrl, Shift, Enter and Tab are
all supported, allowing you to fully navigate the menu of other programs
from within Matlab. If you simply wish to type into another program (as
opposed to navigating a menu), see my other submission "textInject".

Example:
Send some text to Notepad, save it with a specified file name using
Notepad's menu, then return focus to Matlab:
keyInject('Untitled - Notepad','Here is some text I would like to save','Untitled - Notepad')
keyInject('Untitled - Notepad','ALT__FA','Untitled - Notepad')
keyInject('Save As','this is the file name i want.txt\r','Matlab R2012b')

Supported keystrokes:
alphanumeric (a-z,0-9), L Alt ('ALT__'), L Ctrl ('CTRL__'), L Shift
('SHIFT__'), Tab ('\t'), Enter ('\r'), Dash ('-') and Period ('.'). For
capital letters you can hold shift (see below).

Holding down Alt, Ctrl or Shift keys:
Replace the second underscore character with a '+' to hold the key down,
or a '-' to release it. For example to select all text in a window and
copy it to the clipboard: 'CTRL_+AC' (followed by 'CTRL_-' to release).
See the screenshot on the file exchange for an example of how to this in
action (selects text in Matlab and copy-pastes it into Notepad).

Adding new keys: This must be done manually, but it's easy if you copy
the approach I've laid out below. You will need a 'Virtual Key Code':
http://www.kbdedit.com/manual/low_level_vk_list.html
The hex values there need to be converted to decimal:
http://www.kbdedit.com/manual/low_level_vk_list.html
You don't need to recompile the mex files to add new keys.

Mex files: You must compile the included source code to use this utility. The Windows keyboard API uses C++, and so you will need a C++ compiler (the Matlab LCC compiler will not work). Once you have a supported compiler, type mex -setup to select it. Then put the C files on the Matlab path and just type:
mex 'keyInject_setFocus.cc'
mex 'keyInject_sendKey.cc'

인용 양식

Phillip (2024). KeyInject (https://www.mathworks.com/matlabcentral/fileexchange/40001-keyinject), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2012b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기
도움

도움 받은 파일: TextInject

도움 준 파일: Interactive link between MATLAB and ANSYS

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

I updated the description of how to compile the source code, as I realised that the Matlab LCC compiler will not work because this submission uses C++.

1.0.0.0