
매번 같은 일을 반복하면서
"이거 좀 더 쉽게 할 방법 없을까?"
라는 생각, 해본 적 있으시죠?
저도 똑같이 고민하다가, 일상 업무를 몇 분 만에 자동화해주는 파이썬 스크립트들을 발견했습니다.
이 글에서는 제가 직접 사용해본 효율적인 자동화 스크립트 10개를 소개합니다.
개발자든 아니든, 이 스크립트들은 여러분의 시간을 아껴줄 겁니다!
1. SleepNoMore — 컴퓨터 절전 모드 자동 방지
잠깐 자리를 비운 사이 컴퓨터가 슬립 모드로 들어가고,
중요한 회의 중 화면이 꺼져버리는 상황, 겪어본 적 있죠?
이 스크립트는 마우스 커서를 자동으로 움직여서
컴퓨터가 사용 중인 것처럼 인식하도록 만들어줍니다.
화면 잠금이나 자동 로그아웃 방지에 딱!
from pyautogui import moveTo
from datetime import datetime
from time import sleep
from random import randint
def main():
while True:
x = randint(1, 1000)
y = randint(1, 1000)
moveTo(x, y)
sleep(1)
main()
2. Headliner — 데스크탑으로 뉴스 알림 받기
바쁜 하루 중에도 중요한 뉴스를 놓치고 싶지 않다면?
이 스크립트는 NewsAPI를 통해 실시간 뉴스 헤드라인을 받아와
데스크탑 알림으로 바로 띄워줍니다.
중간중간 확인하며 정보 흐름을 유지하고 싶은 분께 추천!
from plyer import notification
import requests
import json
country_code = input("뉴스 국가 코드 입력: ")
api_key = input("뉴스 API 키 입력: ")
news = requests.get(
f'https://newsapi.org/v2/top-headlines?country={country_code}&apiKey={api_key}')
data = json.loads(news.content)
for article in data['articles']:
notification.notify(
title=article['title'][:20],
message=article['description'][:44],
timeout=5,
toast=False)
NewsAPI 공식 사이트에서 무료로 API 키를 발급받을 수 있습니다.
3. EchoType — 음성 입력을 텍스트로 변환
"타이핑 하기 귀찮은데…" 할 때 정말 유용한 스크립트입니다.
내 목소리를 마이크로 입력 받아 텍스트로 출력해주는 간단한 음성 인식 도구예요.
회의록 작성, 아이디어 정리, 메모 등에 활용 가능합니다.
import speech_recognition as sr
def convert_audio_to_text():
r = sr.Recognizer()
with sr.Microphone() as source:
print("말씀해주세요...")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
return text
except sr.UnknownValueError:
print("음성을 인식할 수 없습니다.")
except sr.RequestError as e:
print(f"에러: {e}")
audio_text = convert_audio_to_text()
if audio_text:
print("입력된 음성:", audio_text)
SpeechRecognition
라이브러리와 마이크가 필요합니다.
🖼️ 4. ToonifyMe — 사진을 만화 스타일로 변환
사진을 만화처럼 바꿔주는 필터를 직접 구현해보세요!
이 스크립트는 OpenCV와 k-means 알고리즘을 활용해
이미지를 간단한 카툰 스타일로 변환합니다.
간단한 리프레시 용도로도 좋고, 프로필 이미지로도 활용 가능해요.
import cv2
import numpy as np
def cartoonize_image(img_path, save_path):
img = cv2.imread(img_path)
if img is None:
raise ValueError("이미지를 읽을 수 없습니다.")
data = np.float32(img).reshape((-1, 3))
_, labels, centers = cv2.kmeans(data, 8, None,
(cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 0.001),
10, cv2.KMEANS_RANDOM_CENTERS)
quantized = np.uint8(centers)[labels.flatten()].reshape(img.shape)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.adaptiveThreshold(cv2.medianBlur(gray, 7), 255,
cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 2)
cartoon = cv2.bitwise_and(quantized, quantized, mask=edges)
cv2.imwrite(save_path, cartoon)
if __name__ == "__main__":
cartoonize_image("cartoon.jpg", "cartoon_output.jpg")
사용 전 opencv-python
과 numpy
설치가 필요합니다.
5. BulkBlaster — 이메일 대량 전송 자동화
마케팅 메일, 공지사항, 합격 안내 메일 등 여러 사람에게 이메일을 일일이 보내는 작업, 정말 귀찮죠?
이 스크립트는 엑셀 파일에서 수신자 정보를 읽고, 조건에 따라
맞춤 이메일을 자동 발송합니다.
반복적인 이메일 업무를 확실히 줄여줍니다.
⚠️ smtplib를 사용하는 만큼 Gmail 보안 설정(앱 비밀번호 등)을 미리 설정해두는 것이 좋습니다.
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import xlrd
import time
import smtplib
# 엑셀 파일 열기
path = "selects.xlsx"
File = xlrd.open_workbook(path)
sheet = File.sheet_by_name('Selects')
mail_list = []
interviewerlist = []
name = []
# 엑셀에서 정보 추출
for k in range(1, sheet.nrows):
student = sheet.cell_value(k, 0)
email = sheet.cell_value(k, 1)
passed = sheet.cell_value(k, 3)
interviewer = sheet.cell_value(k, 4)
if passed == 'Yes':
mail_list.append(email)
interviewerlist.append(interviewer)
name.append(student)
# 발신자 정보 입력
email = 'example@gmail.com' # 보내는 이메일
password = '*****' # 앱 비밀번호 또는 이메일 비밀번호
# SMTP 서버 설정
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(email, password)
# 메일 전송
for i in range(len(mail_list)):
receiver = mail_list[i]
student_name = name_list[i]
interviewer = interviewer_list[i]
subject = f'Congratulations {student_name}!! You are selected for further interviews.'
message = f'''Dear {student_name},
We are pleased to inform you that you will be interviewed by {interviewer}.
Please wait for further instructions via email from your interviewer.
Best Regards
'''
# 메일 포맷 구성
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = receiver
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
# 전송
server.sendmail(sender_email, receiver, msg.as_string())
print(f"Sent to {student_name}")
server.quit()
print("모든 메일 전송 완료!")
6. Loopify — 영상 일부를 GIF로 변환
영상의 일부를 간단하게 GIF로 바꾸고 싶을 때 이 스크립트가 딱입니다.
짧은 밈, SNS 공유용 짤 등을 만들 때 유용하며,
MoviePy 라이브러리를 기반으로 빠르게 변환됩니다.
import moviepy.editor as mp
import os
import sys
def convert_to_gif(input_file):
try:
if not os.path.exists(input_file):
print(f"파일이 존재하지 않습니다: {input_file}")
return
output_file = os.path.splitext(input_file)[0] + '.gif'
clip = mp.VideoFileClip(input_file)
clip.write_gif(output_file, fps=10, program='ffmpeg')
clip.close()
except Exception as e:
print(f"에러 발생: {str(e)}")
if __name__ == "__main__":
convert_to_gif(sys.argv[1])
- moviepy, ffmpeg 설치 필요
- 사용 시: python script.py sample.mp4
7. ShoutSite — 웹사이트를 음성으로 열기
"구글 열어줘!" 라고 말하는 것만으로도 브라우저가 열립니다.
이 스크립트는 음성 인식으로 웹사이트를 열어주는 자동 브라우징 도구입니다.
간단하면서도 신기한 자동화 경험이 가능합니다.
import speech_recognition as sr
import webbrowser
def takeCommand():
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("듣고 있어요...")
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
command = recognizer.recognize_google(audio).lower()
print(f"명령어: {command}")
return command
except sr.UnknownValueError:
print("음성을 인식하지 못했습니다.")
return None
except sr.RequestError as e:
print(f"에러: {e}")
return None
def openWebsite(website):
website = website.replace("open", "").replace(" ", "")
url = f"https://www.{website}.com"
webbrowser.open(url)
if __name__ == "__main__":
while True:
command = takeCommand()
if command == "exit":
print("종료합니다.")
break
elif command:
openWebsite(command)
- 예: "Open Google" → https://www.google.com 자동 열림
8. H2OMG — 물 마시기 리마인더
하루 종일 앉아서 일하다 보면 물 마시는 걸 잊기 쉽죠.
이 스크립트는 주기적으로 알림을 띄워 물을 마시도록 알려줍니다.
import time
from plyer import notification
def drink_water_reminder():
title = "💧 물 마시기 알림"
message = "지금 물 한 잔 마실 시간이에요!"
notification.notify(title=title, message=message)
def main():
while True:
time.sleep(1200) # 20분마다
drink_water_reminder()
if __name__ == "__main__":
main()
plyer
설치 필요 (알림 기능)
9. StackSearchr — 에러 메시지로 자동 검색
코드가 에러를 뱉으면 자동으로 Stack Overflow 검색 결과를 열어주는 스크립트입니다.
디버깅 시간 단축에 효과적이에요!
import subprocess
import requests
import webbrowser
file = input("파이썬 파일 이름을 입력하세요: ")
p = subprocess.run(['python', file], capture_output=True, text=True)
s = p.stderr.split("\n")[-2]
errorType = s.split(":")[0]
errorMessage = s.split(":")[1] if ":" in s else ""
URL = "https://api.stackexchange.com/2.2/search"
PARAMS = {
'intitle': errorType,
'tagged': 'python',
'sort': 'votes',
'site': 'stackoverflow'
}
r = requests.get(url=URL, params=PARAMS)
data = r.json()
links = [i["link"] for i in data['items'] if i["is_answered"]]
for link in links[:5]:
webbrowser.open_new_tab(link)
- 에러 메시지를 자동으로 추출해 관련 질문을 검색합니다.
10. Catcher in the Screen — 화면 녹화 스크립트
빠르게 튜토리얼이나 데모 영상을 녹화하고 싶을 때 유용한 화면 녹화 스크립트입니다.
녹화 파일은 .avi
로 저장되며, PyAutoGUI로 화면을 캡처합니다.
import cv2
import numpy as np
import pyautogui
from datetime import datetime
import os
def screen_recorder():
if not os.path.exists('recordings'):
os.makedirs('recordings')
screen_size = pyautogui.size()
filename = f"recordings/screen_recording_{datetime.now().strftime('%Y%m%d_%H%M%S')}.avi"
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(filename, fourcc, 20.0, screen_size)
try:
while True:
screen = pyautogui.screenshot()
frame = np.array(screen)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow('Recording...', frame)
if cv2.waitKey(1) == ord('q'):
break
finally:
out.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
print("녹화를 시작합니다. 'q'를 누르면 종료됩니다.")
screen_recorder()
print("녹화가 완료되었습니다.")
opencv-python
,pyautogui
설치 필요- 결과 영상은
recordings/
폴더에 저장됩니다.
마무리
이 10가지 스크립트는 모두 간단하지만, 실제 일상 속에서 시간을 아껴주는 유용한 도구입니다.
하나씩 실행해보며 직접 써보면 파이썬 자동화의 재미를 제대로 느낄 수 있어요.
'Language > Python' 카테고리의 다른 글
Python 프로젝트 구조화 방법 (0) | 2025.03.10 |
---|---|
일상 작업을 자동화하는 10가지 Python 스크립트 (1) | 2024.12.05 |
파이썬에서 함수형 프로그래밍 실습 (0) | 2024.11.16 |
파이썬 데코레이터(Decorator) 5가지 소개 (1) | 2024.11.15 |
[Python] 디자인 패턴 사용 방법 (2) | 2024.11.14 |
IT 기술과 개발 내용을 포스팅하는 블로그
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!