Hello to all,
First of all, It is not a keyPress/keyRelease issue;
The following code (CODE A) puts MATLAB R2022b in "Busy" mode in macOS Catalina 10.15.7. The crash report is also given below.
FIRST ISSUE:
Is there an alternative method of sending keyboard strokes via MATLAB as in Windows, i.e., Is there some "AppleScript" associated with MATLAB or some "AppleShell"?:
In Windows, one can alternatively use the following to simulate a keyboard hit on letter 'a'
h=actxserver('WScript.Shell');
h.SendKeys('A')
SECOND ISSUE:
When I run "CODE A" given below, It produces '1' in the Command Window and goes into (infinite?) loop without being able to produce '2' in the Command Window.
I have found this solution for MATLAB R2007 :
But, in my macbook, in MATLAB R2022b's 'bin' folder, I could not recognize a resembling .sh file to modify.
In the macbook terminal, "java -version" produces:
java version "19.0.2" 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
My system's specs are as the following:
Macbook Pro 13 inch (Mid 2012), Intel i5 Dual Core 2.5 GHz, 16 GB 1600 MHz DDR3, Intel HD Graphics 4000 1536 MB
Any comments and/or suggestions ? Thank you in advance,
Evrim
%CODE A -This causes infinite loop somewhere in "step 1" and "step 2"
%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
import java.awt.Robot;
import java.awt.event.*;
import java.awt.event.KeyEvent;
rbt = java.awt.Robot;
1 %step 1
rbt.keyPress(java.awt.event.KeyEvent.VK_A);
2 %step 2
pause(0.1)
3
rbt.keyRelease(java.awt.event.KeyEvent.VK_A)
4
%///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Nevertheless, I can control the mouse cursor motion with the following (Code B below works fine):
%CODE B:
%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
import java.awt.Robot;
import java.awt.event.*;
import java.awt.MouseInfo;
mouse = Robot;
pos=[1000 100]
mouse.mouseMove(pos(1), pos(2)); pause(0.1);
s='3';
eval(['mouse.mousePress(InputEvent.BUTTON' s '_MASK);']); pause(0.1);
eval(['mouse.mouseRelease(InputEvent.BUTTON' s '_MASK);']); pause(0.1);
%///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MATLAB Log File: /Users/macpro/matlab_crash_dump.8953-1
------------------------------------------------
MATLAB Log File
------------------------------------------------
--------------------------------------------------------------------------------
Illegal instruction detected at 2023-09-04 14:23:44 +0300
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : maci64
MATLAB Entitlement ID : 1963044
MATLAB Root : /Applications/MATLAB_R2022b.app
MATLAB Version : 9.13.0.2126072 (R2022b) Update 3
OpenGL : hardware
Operating System : Mac OS Sürüm 10.15.7 (Geliştirme 19H2026)
Process ID : 8953
Processor ID : x86 Family 6 Model 58 Stepping 9, GenuineIntel
Session Key : e0f2a998-aa7f-4355-8462-ab9d9c43507b
Window System : Quartz
Fault Count: 1
Abnormal termination:
Illegal instruction
Current Thread: 'MCR 0 interpreter thread' id 0x70000f5a3000
Register State (from fault):
RAX = 1805164b981f0081 RBX = 000060003317f000
RCX = 0000000000000058 RDX = 00000000ed61206e
RSP = 000070000f59e740 RBP = 000070000f59e750
RSI = 000060003317f680 RDI = 00000000ed411858
R8 = 000000000000007f R9 = 00000000000007fb
R10 = 0000000000003680 R11 = 0000000000000080
R12 = 00006000014f91a0 R13 = 000070000f59eb80
R14 = 000070000f59e858 R15 = 0000000000000000
RIP = 00007fff691488f1 RFL = 0000000000010202
CS = 000000000000002b FS = 0000000000000000 GS = 0000000000000000
Stack Trace (from fault):
[ 0] 0x0000000106c49b94 /Applications/MATLAB_R2022b.app/bin/maci64/libmwfl.dylib+00007060 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000052
[ 1] 0x0000000106c4e05a /Applications/MATLAB_R2022b.app/bin/maci64/libmwfl.dylib+00024666 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00006778
[ 2] 0x0000000106c4c2e5 /Applications/MATLAB_R2022b.app/bin/maci64/libmwfl.dylib+00017125 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000149
[ 3] 0x000000010c6a23fc /Applications/MATLAB_R2022b.app/bin/maci64/libmwmcr.dylib+00521212 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011884
[ 4] 0x000000010c6a0483 /Applications/MATLAB_R2022b.app/bin/maci64/libmwmcr.dylib+00513155 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003827
[ 5] 0x000000010c69dd35 /Applications/MATLAB_R2022b.app/bin/maci64/libmwmcr.dylib+00503093 mnFatalSignalHandler+00000149
[ 6] 0x00007fff6939d5fd /usr/lib/system/libsystem_platform.dylib+00013821 _sigtramp+00000029
[ 7] 0x00007fff90597348 /usr/lib/system/libsystem_c.dylib+658142024 __global_locale+00000000
[ 8] 0x00007fff69148886 /usr/lib/system/libdispatch.dylib+00014470 dispatch_assert_queue+00000122
[ 9] 0x00007fff2ecdadc2 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox+00204226 islGetInputSourceListWithAdditions+00000119
[ 10] 0x00007fff2ecdd5b8 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox+00214456 isValidateInputSourceRef+00000090
[ 11] 0x00007fff2ecdd480 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox+00214144 TSMGetInputSourceProperty+00000030
[ 12] 0x00007fff5e8c8bf8 /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight+02329592 ___ZL24key_translate_initializev_block_invoke+00000178
[ 13] 0x00007fff69147658 /usr/lib/system/libdispatch.dylib+00009816 _dispatch_client_callout+00000008
[ 14] 0x00007fff691487de /usr/lib/system/libdispatch.dylib+00014302 _dispatch_once_callout+00000020
[ 15] 0x00007fff5e8c8b44 /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight+02329412 CGSKeyEventTranslate+00000064
[ 16] 0x00007fff5e70e4ed /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight+00517357 SLSCreateKeyboardEventWithFlagsAndStateOfLength+00000440
[ 17] 0x00007fff5e6d670e /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight+00288526 SLSPostKeyboardEvent+00000194
[ 18] 0x00007fff2e37d277 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices+00143991 AXUIElementPostKeyboardEvent+00000106
[ 19] 0x00000001448408fc /Applications/MATLAB_R2022b.app/sys/java/jre/maci64/jre/lib/libawt_lwawt.dylib+00157948 Java_sun_lwawt_macosx_CRobot_keyEvent+00000070
[ 20] 0x000000012eb55667 <unknown-module>+00000000