파이썬 코딩
2024.12.01. [파이썬] 첫GUI ! 자동 문자 보내기📨
37song
2025. 1. 15. 19:36
실전편 강의를 듣고, GUI 만드는 공부를 하고!
처음으로 만들어본 GUI..
엑셀에서 고객의 데이터를 가져와 윈도우의 휴대폰과 연결 프로그램으로 자동 문자 전송
https://cafe.naver.com/startcodingofficial/1423
ㅎㅎ 저도 GUI 한번 만들어 봤습니당 ~ 완성해서 신나요 😁😁😁😁
저는! 녹즙 영업을 하고 있습니다~~ 공장에서 급냉한 녹즙을 한달 단위로 택배로 보냅니다! 실장님께서는 모든 고객들에게 택배 보내기 전날에 문자를 발송합니다~ 배송 알림과 변...
cafe.naver.com

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QWidget
from farmdew_ui import Ui_Form
import sys
import requests
import pandas as pd
import xlwings as xw
import pyperclip
import pyautogui
import time
import keyboard
class MainWindow(QWidget, Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
# self.객체이름.clicked.connect(self.실행할메서드이름)
self.send_massege_btn.clicked.connect(self.send_message)
self.reset_btn.clicked.connect(self.reset)
self.quit_btn.clicked.connect(self.quit)
def send_message(self):
#엑셀 불러오기
df = pd.read_excel(self.file_dir.text())
#발송날짜 입력 후 필터링
send_date = int(self.send_date.text())
x = int(self.mouse_x.text())
y = int(self.mouse_y.text())
df_filtered = df[df['발송'] == send_date]
# 도착 날짜
arrive_date = int(self.arrive_date.text())
# 당일 인원수
count = len(df_filtered)
for i in range(count) :
name = df_filtered.iloc[i,0]
abc = df_filtered.iloc[i,1]
carrot = df_filtered.iloc[i,2]
bori = df_filtered.iloc[i,3]
cabbage = df_filtered.iloc[i,4]
kale = df_filtered.iloc[i,5]
nth = df_filtered.iloc[i,6]
phone = df_filtered.iloc[i,9]
total = abc+carrot+bori+cabbage+kale
if total > 20 :
service = 2
else:
service =1
message = f'안녕하세요!! {name} 고객님^^\n(주)참선진녹즙 상황실입니다~\n프레시스 급냉쥬스 관련하여 배송 확인차 연락드립니다.\n저희 업체에서는 신선식품으로 등록이 되어 있어서 출고시간으로부터 30시간 이내에 배송이 되고 있습니다.\n\n{send_date}일 발송\n{arrive_date}일 도착 예정\n\n{nth}차 주문하신 제품은\nABC {abc}\n당근 {carrot}\n새싹보리 {bori}\n양배추 {cabbage}\n케일 {kale}\n총 {total}+{service}개(서비스) 발송 예정입니다.\n\n결제는 매월 1~2일에 진행됩니다!\n잔고 유지 부탁드립니다!\n제품 및 배송지 변경은 내일 오전 8시까지 문자 부탁드립니다!!\n궁금하신 점 있으시면 연락 주세요!\n오늘은 어제보다 더 많이 웃는 하루 보내시기 바랄게요^^*\n감사합니다~'
pyperclip.copy(message)
# 번호 입력
pyautogui.click(x, y, button='left')
time.sleep(0.3)
pyperclip.copy(phone)
pyautogui.hotkey('ctrl', 'v')
pyautogui.press('enter')
time.sleep(0.3)
pyautogui.press('enter')
time.sleep(0.3)
# 메세지 붙여넣기
pyperclip.copy(message)
pyautogui.hotkey('ctrl', 'v')
pyautogui.press('enter')
time.sleep(0.3)
# 개인 별 전송 완료 메시지 출력
self.textBrowser.append(f'{name} 님에게 전송 완료 !!!\n')
QApplication.processEvents()
self.textBrowser.append(f'~~~ 총 {count}명에게 문자 발송 완료 ~~~')
def reset(self):
self.mouse_x.setText("")
self.mouse_y.setText("")
self.file_dir.setText("")
self.send_date.setText("")
self.arrive_date.setText("")
self.textBrowser.setText("")
def quit(self):
sys.exit()
app = QApplication()
window = MainWindow()
window.show()
sys.exit(app.exec())