Skip to content

Instantly share code, notes, and snippets.

@lschwetlick
Last active June 20, 2017 21:07
Show Gist options
  • Save lschwetlick/8199c5bb3648d4dfc73dc3395b44e4fe to your computer and use it in GitHub Desktop.
Save lschwetlick/8199c5bb3648d4dfc73dc3395b44e4fe to your computer and use it in GitHub Desktop.
MATLAB Hotkeys
; Hotkeys for MATLAB and others
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; Changes the tray icon's tooltip (displayed when mouse hovers over it)
Menu, tray, Tip, MATLAB hotkeys (and others)
; Show Tooltip in the tray that the script is active
TrayTip, MATLAB hotkeys, running...,,1
; Move line down using Page down
PgDn::
;if Matlab is open
IfWinActive, MATLAB
{
ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
Send, {Home}+{End}
Sleep, 10
Send, ^x
Sleep, 150
Send, {Del}{End}{Enter}
Sleep, 150
Send, ^v
Sleep, 200 ; otherwise the wrong text gets pasted
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large.
return
}
;if Matlab is not open. For using line up/down in other text editing programs
else {
ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
Send, {Home}+{End}^x{Del}{End}{Enter}^v
Sleep, 100
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large.
return
}
; Move line up using Page up
PgUp::
IfWinActive, MATLAB
{
ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
Send, {Home}+{End}
Sleep, 10
Send, ^x
Sleep, 150
Send, {Backspace}{Home}{Enter}{Up}
Sleep, 150
Send, ^v
Sleep, 150 ; otherwise the wrong text gets pasted
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large.
return
}
;if Matlab is not open. For using line up/down in other text editing programs
else {
ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
Send, {Home}+{End}^x{Backspace}{Home}{Enter}{Up}^v
Sleep, 100
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large.
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment