Inspiration

It was inspired by horror movies that show blinking lights before a jumpscare or scary scene.
I tried to recreate that tension using Python on digital screens.


What It Does

  1. Initial Setup

    • Creates a fullscreen, transparent window that covers your entire screen
    • The window is click-through initially, meaning you can still use your computer normally
    • Loads background music and sound effects from a sounds folder
    • Starts playing background music that loops continuously
  2. 3-Second Wait

    • The program waits 3 seconds after you run it (building suspense)
  3. Black Screen Blinking (8 blinks)

    • Your screen suddenly turns black
    • It blinks 8 times (alternating between pure black and near-black #050505)
    • Each blink lasts 1 second
    • After blinking, the screen stays black for another 3 seconds
  4. Haunted Notepad Sequence

    • Closes any open Notepad instances using taskkill
    • Opens a fresh Notepad window
    • Changes Notepad font size to 18pt through the Windows Registry
    • Reads text from random.txt
    • Types it character-by-character automatically with keyboard sounds:
      • First 10 characters: slow (0.3 seconds each) — dramatic effect
      • Remaining characters: fast (0.01 seconds each)
      • Each keystroke plays keyboard.mp3 sound
    • Pauses for 3 seconds
    • Goes to a new line and slowly types "DO NOT LOOK BACK" (0.3s per character)
    • Closes Notepad automatically
    • Shows black screen for 3 seconds
  5. Jumpscare

    • Displays a jumpscare.jpg image fullscreen with a scary sound
    • If no image exists, shows a red screen with “BOO!!!” text
    • Waits for the jumpscare sound to finish playing before continuing
  6. Thank You Message

    • Stops all music
    • Shows a message box: “Thank you for executing!”
    • Program exits

How We Built It

Built using Python and a combination of open-source libraries, sounds, and image files.


Challenges We Ran Into

Synchronizing the keyboard sound with the typing animation in Notepad was challenging.
Initially, the sound played after each keystroke, creating a delay.
The fix was to trigger the sound before pyautogui.write() instead of after.


Accomplishments We’re Proud Of

  1. Seamless Multi-Library Integration
    Successfully integrated 4 different Python libraries that don’t normally work together:

    • tkinter (GUI)
    • pygame (sound + events)
    • PIL/Pillow (images)
    • pyautogui (automation)
  2. Advanced Window Transparency Effects
    Created a sophisticated transparent overlay that:

    • Covers the entire screen
    • Remains click-through when needed
    • Can toggle visibility on demand
    • Stays on top of all windows

What We Learned

  1. Multiple Event Systems Can Coexist

    • Lesson: tkinter’s event loop and pygame’s event polling can work together if managed carefully
    • Discovery: pygame.event.get() must be called regularly to drain the event queue, even inside tkinter apps
    • Solution: Regular polling with check_for_escape() keeps both systems responsive
    • Application: Understanding how to bridge event paradigms between libraries
  2. Process Management Requires Aggressive Cleanup

    • Lesson: Applications like Notepad can have multiple instances or linger after use
    • Discovery: taskkill /F is sometimes necessary to ensure a clean state
    • Solution: Force-kill existing processes before starting new ones
    • Application: External process automation often requires aggressive management
  3. Windows Registry Can Control Application Behavior

    • Lesson: System applications like Notepad store settings in the Windows Registry
    • Discovery: Registry values like
      HKCU\Software\Microsoft\Notepad\lfHeight
      control font size
    • Solution: Use reg add to modify application settings programmatically
    • Application: Registry manipulation enables deep system customization

What’s Next for Haunted Window

  1. Configuration File
    • Enhancement: Add config.json for easy customization
    • Benefit: Users can adjust behavior without editing the source code
   {
     "blink_count": 8,
     "blink_speed": 1.0,
     "typing_speed_slow": 0.3,
     "typing_speed_fast": 0.01,
     "haunted_message": "DO NOT LOOK BACK",
     "wait_time": 3
   }

Built With

Share this project:

Updates