본문 바로가기
Python/GUI

[Python_GUI] GUI 실행 예제

by 꾸압 2021. 3. 4.

맥일 경우 선행 설치 필요 (pip install pyobjc-core pyobjc)

pip install pyobjc

 

코드 입력 :

python
import pyautogui
pyautogui.position()

 

예제 (1)

import pyautogui
pyautogui.moveTo(100, 200)
pyautogui.click()
pyautogui.moveRe1(200, 100)

pyautogui.typewrite('abcd')
pyautogui.press('enter')

 

예제 (2) : 카카오톡 실행시켜보기

import subprocess
import pyautogui
import time

# 맥을 쓰는 경우 아래 소스코드 사용
# kakao = subprocess.Popen(['open', '-a', 'KakaoTalk'])

# 윈도우 쓰는 경우 아래 소스코드 사용
# kakao subprocess.Popen([카카오톡이 설치된 경로 입력])
# kakao subprocess.Popen([C:\Program Files (x86)\Kakao\KakaoTalk\KakaoTalk.exe])

time.sleep(5)
ID = 'test'
PWD = 'test'
pyautogui.typewrite(ID)
time.sleep(2)
pyautogui.press('tab')
time.sleep(2)
pyautogui.typewrite(PWD)
time.sleep(2)
pyautogui.press('enter')
time.sleep(2)

댓글