An AutoHotkey v2 utility that types Python code into the active CodeHS editor one character at a time.
CodeHS automatically inserts indentation after Enter. To prevent double indentation, this script measures the leading spaces in each source line but never types those spaces. It lets CodeHS handle indentation increases and sends Shift+Tab only when the source code moves back to a lower indentation level.
Use this tool only where automated typing is permitted. Follow your teacher's, school's, and CodeHS's rules.
- Windows 10 or Windows 11
- AutoHotkey v2
- CodeHS configured to use standard Python indentation
AutoHotkey v1 is not supported.
run.ahk— the applicationsettings.ini— saved defaultsREADME.md— usage and troubleshootingLICENSE— project license
Keep run.ahk and settings.ini in the same folder.
- Install AutoHotkey v2.
- Extract the ZIP file.
- Double-click
run.ahk. - Paste your Python code into the large Code to type box.
- Open CodeHS and place the cursor where the code should begin.
- Click Start Typing.
- During the countdown, focus the CodeHS editor.
- Do not switch windows while typing. Press
F1to stop safely.
The application hides during the countdown. When the countdown ends, it locks onto the active window. If that window loses focus, typing stops instead of continuing into another application.
| Setting | Description | Default |
|---|---|---|
| Start delay | Time available to focus the CodeHS editor | 2000 ms |
| Typing speed | Base pause after each character | 50 ms |
| Random extra delay | Adds a random pause from zero to this value | 50 ms |
| Spaces per indentation level | Used to interpret source indentation | 4 |
| Always on top | Keeps the setup window above other windows | On |
Click Save Settings to write the values to settings.ini. The code in the text box is never saved.
For every non-blank source line, the script separates the line into:
- leading spaces or tabs, used only to calculate the source indentation level;
- the line content, which is the only part typed into CodeHS.
The script then follows these rules:
- When indentation increases, it sends no spaces and lets CodeHS auto-indent.
- When indentation stays the same, it begins typing at CodeHS's current indentation.
- When indentation decreases, it sends one
Shift+Tabfor each level removed. - Blank lines are entered without resetting the remembered indentation level.
- Tabs in the source are measured using the configured indentation size.
This prevents the source's leading spaces from being added on top of CodeHS's automatic indentation.
F1stops both the countdown and active typing.- Typing stops if the selected target window loses focus.
- Settings are checked before typing starts.
- A second typing run cannot start while one is active.
- The script does not add a final Enter unless the input contains a final newline.
- Special characters are sent literally with AutoHotkey's
SendTextfunction.
- The indentation logic is intended for standard Python blocks using a consistent indentation width.
- The first line of a complete program should normally begin at indentation level zero.
- Unusual hanging indentation, intentionally indented multiline-string contents, or mixed indentation may need manual correction.
Shift+Tabmust be mapped to one-level dedentation in the CodeHS editor.- The script targets the active window, not a specific website account or assignment.
Make sure you are running this version of run.ahk. It types Content, not the complete source Line, so normal leading spaces are measured but never sent.
Also verify that the source uses ordinary spaces or tabs. Non-breaking spaces and other unusual Unicode whitespace are not valid normal Python indentation.
Click inside the CodeHS editor and test Shift+Tab manually on an indented blank line. It must remove one complete indentation level. If it does not, CodeHS or the browser may be using a different shortcut.
The CodeHS browser window was not active when the countdown finished, or it lost focus after typing began. Start again and click directly inside the editor during the countdown.
Confirm that AutoHotkey is running in the system tray. Some laptops require Fn+F1 to produce the F1 key.
Increase Typing speed and reduce Random extra delay. Browser performance and editor responsiveness vary between computers.
- Added functional F1 cancellation.
- Replaced single Backspace dedentation with one
Shift+Tabper indentation level. - Fixed trailing spaces being counted as indentation.
- Fixed blank lines resetting indentation state.
- Added tab-aware indentation measurement.
- Prevented an unwanted final newline.
- Added numeric settings validation and bounds.
- Added a working Always-on-Top setting.
- Added target-window focus protection.
- Made settings paths relative to the script folder.
- Updated the interface and documentation.