Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Windows Screen Rotation Hotkeys

A lightweight Windows utility that adds keyboard shortcuts for screen rotation using Python and the Windows API.


Features

  • Rotate the Windows display using keyboard shortcuts.
  • Supports all four standard display orientations:
    • Landscape
    • Portrait
    • Landscape (Flipped)
    • Portrait (Flipped)
  • Works on both laptops and desktop PCs.
  • On laptops, the hotkeys continue to work on both AC power and battery power.
  • No third-party Python packages required.
  • Uses the Windows Display API directly through Python ctypes.
  • Can run silently in the background with pythonw.
  • Can be configured to start automatically when you sign in to Windows.
  • Designed for Windows 10 and Windows 11.

Keyboard Shortcuts

Shortcut Action
Ctrl + Alt + ↑ Landscape
Ctrl + Alt + → Rotate 90°
Ctrl + Alt + ↓ Landscape (Flipped)
Ctrl + Alt + ← Rotate 270°
Right Alt + ↑/→/↓/← Same rotation actions as the corresponding Ctrl + Alt shortcut

Note: The exact behavior of the Right Alt/AltGr key can depend on the keyboard layout and Windows input configuration.


Requirements

  • Windows 10 / Windows 11
  • Python 3.10 or newer
  • A display driver that supports Windows display orientation
  • Permission to create a startup task in Windows Task Scheduler

Check Display Rotation Support

  1. Press Win + I.
  2. Go to System → Display.
  3. Find Display orientation.
  4. If Windows provides options such as Landscape, Portrait, Landscape (flipped), or Portrait (flipped), your system supports display orientation changes.

If Display orientation is missing or unavailable, this utility may not work correctly on that system.


Installation Guide

1. Download the Project

Download or clone this repository and extract it to a convenient folder.

The important file is:

ScreenRotate.py

2. Check Python

Open Command Prompt and run:

python --version

You should see Python 3.10 or newer.

If python is not recognized, install Python and make sure Add Python to PATH is enabled during installation.

3. Create the Project Folder

Open C:\ and create a new folder :

C:\Screen Rotate

Put ScreenRotate.py inside it:

C:\Screen Rotate\ScreenRotate.py

4. Test System Support First

Do not install the program as a startup task immediately. Test it first.

This confirms that the utility works on your PC before you configure it to run automatically.

Step 1 — Run the Script

Open Command Prompt:

cd "C:\Screen Rotate"

Run:

python ScreenRotate.py

Or, you can run the script by right-clicking ScreenRotate.py and selecting Run with Python.

Now test all Ctrl + Alt + Arrow and Right Alt + Arrow shortcuts.

If everything works, press Ctrl + C to stop the test and close cmd.

Step 2 — Test Background Mode

Run:

pythonw.exe "C:\Screen Rotate\ScreenRotate.py"

Hit enter & simply close cmd.

Test the shortcuts again.

If everything works

  • Stop here and confirm that all shortcuts work correctly.

  • Only after the test is successful should you continue to the manual installation below.

If the test does not work

  • Do not configure Task Scheduler yet.

Check the troubleshooting section at the bottom first.


Installation For Auto StartUp — Task Scheduler

Step 1 — Find pythonw.exe

Open Command Prompt and run:

where pythonw

Windows should return a path similar to:

"C:\Program Files\Python314\pythonw.exe"

Copy the path shown on your computer or you can minimize the cmd.

Do not copy the example path above. Use the actual path returned by where pythonw.

Step 2 — Open Task Scheduler

  1. Click the Start button.
  2. In the Windows Search box, type:
    Task Scheduler
    
  3. Open Task Scheduler from the search results.

Step 3 — Create the Task

  1. Open Task Scheduler Library.
  2. Click on Create Task...

Step 4 — General tab

Set:

  • Name: Display Rotation Hotkey
  • Run only when user is logged on: Checked✅
  • Run with highest privileges: Unchecked❌

Step 5 — Trigger tab

Open Triggers → Click New...

Set:

  • Begin the task: At log on
  • Select Any user
  • At bottom Enabled: Checked✅

Click OK.

Step 6 — Action Tab

Open Actions → Click New...

Set:

  • Action: → Start a program

  • Program/script:

    Now enter the exact pythonw.exe path perviously you copy from:

    where pythonw

    For example:

      "C:\Program Files\Python314\pythonw.exe"
    

    or you can Browse pythonw.exe file location

  • Add arguments:

    "C:\Screen Rotate\ScreenRotate.py"
    

Click OK.

Step 7 — Conditions tab

For both laptops and desktop PCs:

  • Unchecked❌ Start the task only if the computer is idle
  • Unchecked❌ Start the task only if the computer is on AC power
  • Unchecked❌ Stop if the computer switches to battery power
  • Unchecked❌ Wake the computer to run this task
  • Unchecked❌ Start only if a network connection is available

For Laptop in Battery

Make sure:

Start the task only if the computer is on AC power is unchecked.

And:

Stop if the computer switches to battery power is unchecked.

This keeps the hotkeys working on both battery and AC power in laptops.

Step 8 — Settings tab

Use:

  • Checked✅ Allow task to be run on demand
  • Checked✅ Run task as soon as possible after a scheduled start is missed
  • Checked✅ If the task fails, restart every: 1 minute
  • Attempt to restart up to: 3 times
  • Unchecked❌ Stop the task if it runs longer than
  • Unchecked❌ If the task it is not scheduled to run again, delete it after
  • If the task is already running: Do not start a new instance

Click OK.

Step 9 — Run the Task

  1. Select Display Rotation Hotkey showing in the photo. image
  2. Right-click → Run.
  3. Test all rotation shortcuts.
  4. If everything works, restart Windows.
  5. Log in and test the shortcuts again.

Uninstall

  1. Open:
Task Scheduler
  1. Click Task Scheduler Library.
  2. Select Display Rotation Hotkey.
  3. Right-click → Delete.
  4. Delete:
C:\Screen Rotate

Troubleshooting

Hotkeys work in python mode but not after restart

Check Task Scheduler:

  • The task exists.
  • The trigger is At log on.
  • The action points to the correct pythonw.exe.
  • The script path is correct.
  • Start in is C:\ScreenRotate.

python is not recognized

Run:

where python

If nothing is returned, Python may not be installed correctly or may not be in PATH.

pythonw is not recognized

Run:

where pythonw

Use the full returned path in Task Scheduler.

Screen orientation does not change

First check:

Settings → System → Display → Display orientation

If Windows itself cannot change the orientation, this utility cannot force the rotation through the same Windows display API.

CPU usage is unusually high

Normally the background utility should spend almost no CPU while idle.

Open:

Task Manager → Details

Check for multiple pythonw.exe processes.

If more than one copy is running, make sure you are not using both Task Scheduler and another startup method.

Right Alt shortcuts do not work

The Right Alt key may be interpreted as AltGr depending on the Windows keyboard layout.

Try the normal:

Ctrl + Alt + Arrow

shortcuts first.


Notes

  • This project uses the Windows API through Python ctypes.
  • No third-party Python package is required.
  • Use Task Scheduler as the automatic startup method.
  • Do not run multiple copies of ScreenRotate.py at the same time.
  • The hotkeys are designed to work on laptops and desktop PCs.
  • On laptops, the Task Scheduler configuration allows the program to work on AC power and battery power simultaneously.
  • On laptops with multiple graphics adapters, behavior can depend on which adapter controls the active display.
  • The task does not require an Internet connection or an idle computer.
  • If Windows does not provide a Display orientation option, the display/driver configuration may not support this method.
  • If you modify the script, test it manually before changing the startup configuration.

License

MIT License.

About

Windows screen rotation hotkeys for Windows 11 using Python and the Windows API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages