Stuart’s MATLAB Videos

Watch and Learn

AutoHotkey Shortcuts for the MATLAB Editor

I created some AutoHotkey shortcuts to make it easier to execute arbitrary lines of code in the MATLAB Editor. They include:

  • Alt+Enter: Execute the line I am currently editing/typing
  • Alt+Left Click: Execute the line just clicked
  • Alt+Mouse Select: Execute selected code
  • Here, I’ll show you some examples of using them. AHK file is below.

    Play the video in full screen mode for a better viewing experience. 

    AutoHotkey .ahk file is:

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    #SingleInstance Force
    
    ; Alt+Enter -> Execute current line of code using F9
    !Enter:: ; Alt+Enter
    Send, {End}
    Send, +{Home}
    Send, {F9}
    Send, {Home}
    return
    
    ; Alt+Click, Alt+Click-Drag/select -> Execute clicked line of code, or click-drag-selected lines of code using F9.
    ~!LButton:: 
    ~!LButton Up:: ; Alt+Left Click Up (pass-through)
    
    if (A_TimeSincePriorHotkey<500){
    	; Mouse click and drag-select
    	Send, {End}
    	Send, +{Home}
    	Send, {F9}
    	Send, {Home}
    } else {
    	; Just Mouse click
    	Send, {F9}
    }
    return
    
    |
    • print

    Comments

    To leave a comment, please click here to sign in to your MathWorks Account or create a new one.