-
[python] pyautogui를 이용한 카톡 메세지 전송IT/python 2021. 12. 12. 16:40
# 관련 포스팅: [프로젝트][2021-12] trading view의 웹훅을 수신받아 카톡방에 전송하는 프로그램 구현
카카오톡 api는 단체 채팅방에 관련된 기능을 지원하지 않는다. (근데 왜지..?)
그래서 생각했다. 단톡방에 그럼 어떤식으로 메세지를 보낼 수 있을까?
가장 간단하고 원초적인 방법을 사용했다. 인간이 보내는 방식 그대로 채팅방의 채팅창을 클릭하고
엔터를 눌러서 전송하는 방법을 사용했다.
# 필요 라이브러리
#######################################################################################
python 3.7 version (32bit)
Name: PyAutoGUI
Version: 0.9.53
Summary: PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
Home-page: https://github.com/asweigart/pyautogui
Author: Al Sweigart
Author-email: al@inventwithpython.com
License: BSD
Location: c:\users\home\anaconda3\envs\py37_32\lib\site-packages
Requires: pymsgbox, pyscreeze, pygetwindow, PyTweening, mouseinfo
Required-by:#######################################################################################
# 코드
#######################################################################################
import pyautogui import pyperclip def send_msg(x, y, txt, delay=0.1): ''' 정해진 좌표로 이동하여 메세지를 작성하고 엔터키를 누르는 함수 :param x: x좌표 :param y: y 좌표 :param txt: 텍스트 :param delay: 마우스 포인터가 움직이는 데 걸리는 시간 :return: ''' if x == 0 or y == 0: return pyautogui.moveTo(x, y, delay) pyautogui.click() pyperclip.copy(txt) pyautogui.hotkey('ctrl', 'v') pyautogui.press('enter') send_msg(3638, 975, 'Hello World', 3)
#######################################################################################
# 실행화면
#######################################################################################
#######################################################################################
'IT > python' 카테고리의 다른 글
[python] mysql 이용하기 (0) 2021.12.12 [python] trading view webhook 수신하기 (0) 2021.12.12 [python] PyJWT 오류 해결 (0) 2021.12.12 [python] 한컴뷰어 없이 hwp파일 pdf로 변환 (0) 2021.12.12 [python] 한컴뷰어 없이 hwp파일 텍스트 추출하기 (0) 2021.12.12