Unlock Notepad's Hidden Potential: Fun Programming Tricks You Should Know
Notepad, the unassuming text editor ubiquitous in Windows operating systems, is often perceived as a basic tool for simple note-taking. However, beneath its minimalist interface lies a surprising capability: the ability to execute simple programming tricks. While developers utilize more sophisticated Integrated Development Environments (IDEs) for complex projects, Notepad can be a playground for exploring fundamental coding concepts and creating amusing functionalities. Even users without extensive technical expertise can leverage Notepad to perform a range of entertaining tricks. This article unveils five intriguing Notepad programming tricks that can impress friends, add a spark of fun to your day, or simply demonstrate the unexpected versatility of this humble application.
Notepad Programming Tricks¶
Explore these five engaging Notepad programming tricks, perfect for surprising your peers or injecting a bit of technological amusement into your surroundings. These tricks showcase that even the most basic tools can be used creatively to achieve interesting results. By simply copying and pasting provided code snippets into Notepad and saving them with specific file extensions, you can unlock hidden functionalities and witness Notepad in an entirely new light.
- Typing Slow
- Matrix Animation
- Keyboard Disco Trick
- Password Generator
- Shutdown PC using Notepad
To embark on these Notepad adventures, simply open Notepad, copy the provided code for each trick, and save it with the indicated file extension. Executing these saved files will unleash the programmed functionalities, often with surprising and entertaining outcomes.
1] Typing Slow¶
This trick ingeniously manipulates the typing response speed on your computer, creating a delayed and deliberate typing effect. Imagine the amusement of demonstrating seemingly slow typing to someone, only to reveal it’s a programmed effect achieved with a few lines of code in Notepad. This trick provides a simple yet impactful way to understand basic scripting and its ability to control system behaviors.
To experience the “Typing Slow” effect, copy the following Visual Basic Script (VBScript) code into Notepad and save the file as slowtype.vbs
.
WScript.Sleep 180000
WScript.Sleep 10000
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 100
WshShell.AppActivate "Notepad"
WScript.Sleep 500
WshShell.SendKeys "Hel"
WScript.Sleep 500
WshShell.SendKeys "lo "
WScript.Sleep 500
WshShell.SendKeys ", ho"
WScript.Sleep 500
WshShell.SendKeys "w a"
WScript.Sleep 500
WshShell.SendKeys "re "
WScript.Sleep 500
WshShell.SendKeys "you"
WScript.Sleep 500
WshShell.SendKeys "? "
WScript.Sleep 500
WshShell.SendKeys "I a"
WScript.Sleep 500
WshShell.SendKeys "m g"
WScript.Sleep 500
WshShell.SendKeys "ood"
WScript.Sleep 500
WshShell.SendKeys " th"
WScript.Sleep 500
WshShell.SendKeys "ank"
WScript.Sleep 500
WshShell.SendKeys "s! "
How it works:
This script leverages VBScript commands to introduce delays and simulate keystrokes. WScript.Sleep
commands pause the script execution for a specified number of milliseconds. The initial WScript.Sleep 180000
and WScript.Sleep 10000
commands introduce a significant initial delay before any action occurs. Set WshShell = WScript.CreateObject("WScript.Shell")
creates an object that allows the script to interact with the Windows shell. WshShell.Run "notepad"
opens a new Notepad window. WshShell.AppActivate "Notepad"
brings the Notepad window to the foreground. Subsequent WScript.Sleep
commands, each set to 500 milliseconds, introduce short pauses between each WshShell.SendKeys
command. WshShell.SendKeys
simulates typing the specified characters into the active window, in this case, Notepad. By strategically placing delays between each character sent, the script creates the effect of slow, deliberate typing, spelling out “Hello, how are you? I am good thanks!”.
2] The Matrix Animation¶
Inspired by the iconic sci-fi film “The Matrix,” this trick recreates a simplified digital rain effect reminiscent of the movie’s opening credits. While a full-fledged Matrix simulation is complex, this Notepad trick captures the essence of cascading characters, providing a visually engaging and somewhat nostalgic experience. It demonstrates how basic batch scripting can generate dynamic and visually interesting outputs directly within the command prompt.
To witness the Matrix animation, copy the following batch script code into Notepad and save the file as matrix.bat
.
@echo off
color 02
:tricks
echo %random%%random%%random%%random%%random%%random%%random%%random%
goto tricks
How it works:
This script utilizes batch commands to generate a continuous stream of random numbers in a green color, mimicking the Matrix digital rain. @echo off
disables the command echoing, ensuring only the output is displayed. color 02
sets the command prompt text color to green (0 for black background, 2 for green text). :tricks
defines a label for the loop. echo %random%%random%%random%%random%%random%%random%%random%%random%
displays eight random numbers concatenated together. %random%
is a batch command that generates a random number between 0 and 32767. goto tricks
creates an infinite loop, causing the script to continuously execute from the :tricks
label, generating a never-ending stream of random numbers scrolling down the command prompt window, thus creating the Matrix animation effect.
3] Keyboard Disco Trick¶
This playful trick transforms your keyboard’s lock keys (Caps Lock, Num Lock, Scroll Lock) into flashing disco lights. If you have a keyboard with LED indicators for these keys, this script will make them blink rhythmically in a choreographed sequence, resembling a mini disco light show. This trick is a fun demonstration of how scripting can interact with hardware elements of your computer, albeit in a simple on/off manner for the lock keys.
To activate the Keyboard Disco trick, copy the following VBScript code into Notepad and save the file as disco.vbs
.
Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wshshell.sendkeys "{NUMLOCK}"
wshshell.sendkeys "{SCROLLLOCK}"
loop
How it works:
This VBScript code repeatedly toggles the state of the Caps Lock, Num Lock, and Scroll Lock keys, causing their LED indicators to flash. Set wshShell =wscript.CreateObject("WScript.Shell")
creates an object to interact with the Windows shell. do...loop
creates an infinite loop, ensuring continuous execution. wscript.sleep 100
pauses the script for 100 milliseconds (0.1 seconds) between each key toggle, controlling the blinking speed. wshshell.sendkeys "{CAPSLOCK}"
, wshshell.sendkeys "{NUMLOCK}"
, and wshshell.sendkeys "{SCROLLLOCK}"
send commands to toggle the respective lock keys. Each time sendkeys
is called with one of these key names, it reverses the current state of the key – if it’s on, it turns off, and if it’s off, it turns on. The rapid toggling within the loop creates the disco light effect on the keyboard’s indicator LEDs. To stop the disco effect, you will need to manually stop the script execution, usually by closing the script’s process in Task Manager.
4] Password Generator¶
Creating strong and unique passwords is crucial for online security, but it can sometimes be a tedious task. This Notepad trick offers a simple password generator that can quickly produce random passwords directly within the command prompt. While not as sophisticated as dedicated password managers, this trick provides a handy way to generate passwords on the fly, especially when you need a quick, random string of characters. It showcases how batch scripting can be used to create interactive command-line tools.
To utilize the Password Generator, copy the following batch script code into Notepad and save the file as password_generator.bat
.
@echo off
:Start2
cls
goto Start
:Start
title Password Generator
echo I will make you a new password.
echo Please write the password down somewhere in case you forget it.
echo ----------------------------------------------------------
echo 1) 1 Random Password
echo 2) 5 Random Passwords
echo 3) 10 Random Passwords
echo Input your choice
set input=
set /p input= Choice:
if %input%==1 goto A if NOT goto Start2
if %input%==2 goto B if NOT goto Start2
if %input%==3 goto C if NOT goto Start2
:A
cls
echo Your password is %random%
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2
:Exit
exit
:B
cls
echo Your 5 passwords are %random%, %random%, %random%, %random%, %random%.
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2
:C
cls
echo Your 10 Passwords are %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2
How it works:
This batch script creates a simple command-line interface for generating random passwords. @echo off
disables command echoing. :Start2
and :Start
are labels used for program flow control. cls
clears the command prompt screen. title Password Generator
sets the command prompt window title. echo
commands display text to the user, providing instructions and menu options. set input=
clears any previous value of the input
variable. set /p input= Choice:
prompts the user to enter their choice (1, 2, or 3) and stores it in the input
variable. if %input%==1 goto A if NOT goto Start2
, if %input%==2 goto B if NOT goto Start2
, and if %input%==3 goto C if NOT goto Start2
use conditional goto
statements to jump to different sections of the script based on user input. If the input is invalid, it loops back to :Start2
. :A
, :B
, and :C
labels mark sections for generating 1, 5, or 10 random passwords respectively. In each section, cls
clears the screen, echo Your password is %random%
(or similar for multiple passwords) displays the generated random passwords using the %random%
command. The script then prompts the user to choose to go back to the beginning or exit, using similar input and goto
logic to control the program flow. :Exit
label marks the section where the script terminates using the exit
command. The generated passwords are simply random numbers, which are not ideal for strong security in real-world scenarios but serve as a basic example of password generation.
5] Shut down PC using Notepad¶
This trick transforms Notepad into a quick shutdown switch for your computer. Instead of navigating through menus to shut down, you can simply execute this script, and your system will initiate the shutdown process. This can be a convenient shortcut for frequent shutdowns and demonstrates how scripting can automate system-level tasks. It’s important to use this trick responsibly as it initiates an immediate shutdown.
To create a shutdown switch, copy the following batch script code into Notepad and save the file as shutdown.bat
.
@echo off
msg * System will now shut down
shutdown -c "Bye!" -s
How it works:
This batch script uses system commands to display a shutdown message and initiate the shutdown process. @echo off
disables command echoing. msg * System will now shut down
displays a message box with the title “Message” and the content “System will now shut down” to all users currently logged in (*
indicates all users). shutdown -c "Bye!" -s
executes the shutdown command. shutdown
is the Windows command-line tool for managing shutdowns. -c "Bye!"
adds a comment “Bye!” to the shutdown message displayed to the user. -s
initiates a full system shutdown. When this script is executed, it will first display a warning message and then proceed to shut down the computer after a short delay (default shutdown timer). Be cautious when using this script, as it will immediately start the shutdown process. Save your work before running it.
These Notepad tricks demonstrate that even a simple text editor can be used for more than just writing notes. By leveraging basic scripting languages like VBScript and batch scripting, you can unlock hidden functionalities and create fun, interactive effects. Experiment with these tricks and explore the possibilities of Notepad as a tool for simple programming explorations.
Do you know any other fun or interesting tricks that can be done with Notepad? Share your ideas and suggestions in the comments below!
Post a Comment