Code covered by the BSD License  

Highlights from
inputEmu: Keyboard & Mouse Emulator (v1.0.1)

5.0

5.0 | 7 ratings Rate this file 52 Downloads (last 30 days) File Size: 7.05 KB File ID: #28603

inputEmu: Keyboard & Mouse Emulator (v1.0.1)

by Kesh Ikuma

 

31 Aug 2010 (Updated 20 Sep 2010)

A Java-based function to control keyboard & mouse programmatically

| Watch this File

File Information
Description

INPUTEMU emulates user inputs via keyboard and mouse.

For example, executing the following line in the Matlab command window

inputemu({...
   'key_normal','Hello World\ENTER'
   'right_down',[];'right_up' []}') % <= notice the transpose!

yields in "Hello World" typed and executed in MATLAB command window (followed by an obvious error message) and right mouse click menu. For the detailed instructions, please run 'help inputemu'.

This function is a successor to my earlier submission JMOUSEEMU (linked below) with several notable changes:

* Added keyboard input support
* Changed input argument order
* Multiple-command CMDS input argument transposed (i.e., commands defined in columns not in rows)
* Removed support for Matlab HG specification

Also, as a future enhancement, I am planning to support non-US keyboards. The current version most likely produces incorrect characters for many non-alphabet characters with non-US keyboards. To improve this, please post here or contact me directly with feedback (as I only own QWERTY US keyboards)!

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
jMouseEmu: Mouse Emulator (v2.2)
This submission has inspired the following:
jMouseEmu: Mouse Emulator (v2.2)

MATLAB release MATLAB 7.10 (2010a)
Other requirements Java.awt support
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (28)
17 Sep 2010 Y Mehta  
20 Sep 2010 Y Mehta

I get an error with alternate and extend options.

inputemu('alternate',[1000 1000]);

??? Undefined variable "KeyEvent" or class "KeyEvent.VK_CONTROL".

Error in ==> inputemu>convertToLowLevelActions at 347
params{I} = KeyEvent.VK_CONTROL;

Error in ==> inputemu at 119
[actions,params,dt,msg] = convertToLowLevelActions(cmds,deltaT,idx_mouse,oemChars);

20 Sep 2010 Kesh Ikuma

@Yogesh - Thx for the report. The bug has been fixed and updated version has been upped.

20 Sep 2010 Y Mehta

Thanks. I will download the new version. This is a fantastic program. I am using this to create self training files for my softwares.

23 Sep 2010 Johannes Korsawe

Really nice tool. I did not even think, that this could be working.

Is there any way to "record" your mouse&keyboard actions in order to replay them lateron with your program?

Best regards,
Johannes

23 Sep 2010 Kesh Ikuma

@Johannes - Yes, I have written the "recorder" but not up'ed here yet since it's a (32-bit) Windows specific MEX function (TMW does not accept binary file submission here).

For your disposal, you can download the MEX binary from

http://tinyurl.com/2cxvgwy (Links to my Google Doc)

Read help text for inputlog.m for details but what this function returns can be used as the command cell matrix for inputemu.m.

Use it at your own discretion. And, again, this program is intended for 32-bit Windows. I will eventually post the source here at FEX but probably not in immediate near future.

22 Nov 2010 pri dec  
16 Dec 2010 lin

Excellent Programe, I can't not love it more. Thank you Soooo much

25 Mar 2011 Yuki  
25 Mar 2011 Yuki

I like this. Thanks.
Is it possible to use Function-key?
e.g. F5 for debug continue.

25 Mar 2011 Kesh Ikuma

@Yuki - Yes, function keys are supported (I mistakenly left them out in the help text). Use '\F5' for F5 key press, and similar syntax for the others.

27 Mar 2011 Yuki

Thank you for the prompt reply.
I use inputemu('key_normal','\F5'),
but I get a error of Invalid key @inputme at 120.

Is it depend on keyboard type?
My keyboard is japanese type.

27 Mar 2011 Kesh Ikuma

@Yuki - My bad, use '\F05' instead. It needs to be '\F##' with two digit number.

28 Mar 2011 Yuki

Thank you very much for your kind advice and great code.
I can use inputemu successfully.

06 Sep 2011 Stanv13

hi, excellent program to a question, please is posible use 3 keys at once, according to your syntax is only possible 2. Example Ctrl + Alt + C. Is posible?? or changes must be made, thanks

06 Sep 2011 Kesh Ikuma

@Stan - Yes you can but you have to use the lower level commands: 'key_up' and 'key_down'.

'key_down' CTRL
'key_down' ALT
'key_normal' C
'key_up' ALT
'key_up' CTRL

would achieve your example.

07 Sep 2011 Ha

Is a combination of more than two keys supported?

How to emulate Ctrl+Alt+C?

20 Jan 2012 George

I get the following error while trying to use the program:

Attempt to execute SCRIPT varargin as a function:
C:\Program Files\MATLAB\R2011b\toolbox\matlab\lang\varargin.m

Error in inputemu (line 115)
[cmds,deltaT,idx_mouse,oemChars,msg] =
parseInput(defaultOemChars,nargin,varargin);

Sorry if I'm doing something wrong, I'm rather new to MatLab

20 Jan 2012 George

nevermind I figured it out...bravo

29 Mar 2012 Hanna

Hey! This might be an easy question, but does anyone know how to make the keyboard type the content of a variable you have set?
For instance:
variable= test 1
inputemuu(‘key_normal’,variable)

I would like this to type “test 1″
Any help would be appreciated :)

29 Mar 2012 Kesh Ikuma

@Hanna, your example works the way you have it. You might want to make sure that the cursor is placed on the window where you want to type the text to

29 Mar 2012 Hanna

Wow, sorry, the problem was that my variable wasnt saved as characters.. me so stupid. Thanks for the help!

24 Apr 2012 ravish kumar

sir,i m trying to implement this function in a c prgrm.matlab compiler once compiled the fyl and it worked fine.bt now it is showing problem.Though it gets compiled,bt it doesnt do desired task ,ehen .exe file is executed..instead,it shows error!!!!!!!!!!!!!

24 Apr 2012 Kesh Ikuma

@Ravish, I highly doubt that this function would work in the manner you are trying to use it. This function utilizes Java library within Matlab, which is likely inaccessible by a standalone C program as is. Although I'm not familiar with it, I suggest you to look into Java Native Interface.

29 Apr 2012 ravish kumar

thank you sir for the reply.INPUTEMU function is running fine in standalone c application devloped on my pc which have matab installed.
I will let u know if this standalone application fails on other pc without matlab!!!!!!!!!!

30 Apr 2012 ravish kumar

sir, can u illustrate how to emulate ctrl+shift+y.
Comments above regarding this is not clear!!!!!!!

30 Apr 2012 Kesh Ikuma

oops, insert a comma (,) between KEYBOARD_ACTION and key in each call

30 Apr 2012 Kesh Ikuma

Another possibility (the simplest):

inputemu('key_ctrl','Y');

On paper, this should do what you want to do, but donno for sure if it'll work. Please post your results.

Please login to add a comment or rating.
Updates
20 Sep 2010

Fixed a bug in subfunction, convertToLowLevelActions()

20 Sep 2010

previous v1.0.1 upload incorrect

Tag Activity for this File
Tag Applied By Date/Time
utility Kesh Ikuma 31 Aug 2010 11:27:01
java Kesh Ikuma 31 Aug 2010 11:27:01
automation Kesh Ikuma 31 Aug 2010 11:27:01
keyboard Kesh Ikuma 31 Aug 2010 11:27:01
mouse Kesh Ikuma 31 Aug 2010 11:27:01
emulator Kesh Ikuma 31 Aug 2010 11:27:01
keyboard Jose Ercolino 05 May 2012 14:12:49
mouse Jose Ercolino 05 May 2012 14:12:50
automation Jose Ercolino 05 May 2012 14:13:09
emulator Jose Ercolino 05 May 2012 14:13:11

Contact us at files@mathworks.com