Created
April 17, 2012 19:50
-
-
Save mbauman/2408587 to your computer and use it in GitHub Desktop.
Attempt at implementing http://stackoverflow.com/questions/10033078/matlab-implementing-what-ctrlc-does-but-in-the-code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function postKeyEvent | |
import java.awt.event.KeyEvent | |
import java.util.Calendar | |
import java.lang.reflect.* | |
cmdwin = handle(com.mathworks.mde.desk.MLDesktop.getInstance.getClient('Command Window').getComponent(0).getComponent(0).getComponent(0),'CallbackProperties'); | |
cal = Calendar.getInstance(); | |
tnow = cal.getTime().getTime(); | |
keyEvent = KeyEvent(cmdwin,KeyEvent.KEY_TYPED,tnow,0,KeyEvent.VK_UNDEFINED,'c'); | |
argSig = javaArray('java.lang.Class',1); | |
argSig(1) = keyEvent.getClass(); | |
args = javaArray('java.lang.Object',1); | |
args(1) = keyEvent; | |
method = cmdwin.getClass().getDeclaredMethod('processKeyEvent',argSig); | |
method.setAccessible(true); | |
method.invoke(cmdwin,args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment