Skip to content

Commit 40ad56b

Browse files
author
Caspar Gruijthuijsen
committed
autohotkey sleep time is modifiable now
1 parent 7fa6145 commit 40ad56b

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

AutoMatlab.sublime-settings

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
// to return the focus to Sublime again.
3737
"auto_hotkey_return_focus": true,
3838

39+
// The AutoHotkey script to send commands to Matlab by default
40+
// introduces about 500 ms of sleep time to wait for command
41+
// completion. This sleep time can be modified. For instance,
42+
// if the window focus is not returned to Sublime, it might
43+
// help to extend the sleep time.
44+
"auto_hotkey_sleep_multiplier": 1,
45+
3946
// Number of commands from the Matlab history to list in
4047
// the AutoMatlab command panel.
4148
"matlab_history_length": 200,
@@ -74,8 +81,8 @@
7481
"matlab_completions": true,
7582

7683
// Specify the format used for documenting functions in the
77-
// current folder or project. If set to true, AutoMatlab accepts
78-
// any documentation format. If set to false, AutoMatlab expects
84+
// current folder or project. If set to `true`, AutoMatlab accepts
85+
// any documentation format. If set to `false`, AutoMatlab expects
7986
// the same documentation format as used for the built-in Matlab
8087
// functions. In this latter case, AutoMatlab can generate richer
8188
// completions, but will fail to generate completions for functions

ahk/run_in_matlab.ahk

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ SendMode Input ; Recommended for new scripts due to its superior speed and reli
77
SublimeID := WinExist("A")
88
MatlabID := WinExist("ahk_exe matlab.exe")
99

10+
; Read sleep time multiplier
11+
sleep_multiplier = %3%
12+
1013
; Open Matlab window
1114
if WinExist("ahk_id" . MatlabID) {
1215
WinActivate, ahk_id %MatlabID%
13-
Sleep 100
16+
slp := 100 * sleep_multiplier
17+
Sleep %slp%
1418
}
1519
else {
1620
MsgBox,,Sublime AutoMatlab, AutoHotkey cannot find process matlab.exe.
@@ -20,13 +24,15 @@ else {
2024
; Focus the Command window
2125
if WinActive("ahk_id" . MatlabID) {
2226
Send ^0
23-
Sleep 200
27+
slp := 200 * sleep_multiplier
28+
Sleep %slp%
2429
}
2530

2631
; Insert and submit command
2732
if WinActive("ahk_id" . MatlabID) {
2833
Send, %1%{Enter}
29-
Sleep 200
34+
slp := 200 * sleep_multiplier
35+
Sleep %slp%
3036
}
3137

3238
; Return to Sublime window

auto_matlab_commands.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def run(self, command):
272272
# read ahk settings
273273
settings = sublime.load_settings('AutoMatlab.sublime-settings')
274274
ahk_return_focus = settings.get('auto_hotkey_return_focus', True)
275+
ahk_sleep_multiplier = settings.get('auto_hotkey_sleep_multiplier', 1)
275276
ahk_path = settings.get('auto_hotkey_path', 'default')
276277
if ahk_path == 'default':
277278
ahk_path = config.DEFAULT_AUTO_HOTKEY_PATH
@@ -308,8 +309,11 @@ def run(self, command):
308309
'\r\n', '\n'))
309310

310311
# run command
311-
subprocess.Popen([ahk_path, ahk_script_path, command,
312-
'1' if ahk_return_focus else '0'])
312+
subprocess.Popen([ahk_path,
313+
ahk_script_path,
314+
command,
315+
'1' if ahk_return_focus else '0',
316+
str(ahk_sleep_multiplier)])
313317

314318

315319
class ToggleAutoHotkeyFocusCommand(sublime_plugin.WindowCommand):

0 commit comments

Comments
 (0)