[Python RPA] [Python] - 모듈탐구 pyautogui - Python 폴터가이스트

[Python] - 모듈탐구 pyautogui - Python 폴터가이스트

pyautogui는 외장모듈이다. 모듈명 그대로 다운로드 가능하다.

pip3 install pyautogui

역할은 마우스, 키보드의 입력 / 이동을 Python으로 조절하기 위한 모듈이다. 흔히 마우스 마음대로 움직이거나, 키보드가 맘대로 쳐지면 이와 비슷한 모듈이 들어가 있다고 보면 된다.


주요 함수 설명

  • pyautogui.size() : 현재 모니터의 해상도를 (x,y) tuple로 반환한다.
  • pyautogui.onScreen(x,y) : 좌표 x,y의 위치가 모니터 안에서 유효한 좌표인지 bool값으로 반환한다.
  • pyautogui.position() : 현재 마우스의 위치를 반환한다.
  • pyautogui.moveTo(x,y,duration=num_seconds) : duration에 적힌 기간동안 x,y의 좌표로 마우스를 이동한다.
  • pyautogui.moveRel(xoffset,yoffset,duration=num_seconds) : duration에 적힌 기간동안 xoffset, yoffset 만큼 마우스를 이동한다.
  • pyautogui.dragTo(x,y,duration=num_seconds) : duration에 적힌 기간동안 x,y로 마우스를 드래그(클릭 후 이동)한다.
  • pyautogui.dragRel(xoffset,yoffset,duration_num_seconds) : duration에 적힌 기간동안 xoffset, yoffset 만큼 마우스를 드래그(클릭 후 이동)한다.
  • pyautogui.click(x=moveToX,y=moveToY,clickes=num, interval=secs_betweens_clicks,button="left") : 현재위치에서 클릭한다. parameter로는 옆과 같은것을 줄 수 있다.
  • pyautogui.rightClick(x=moveToX,moveToY) : 우클릭
  • pyautogui.middleClick(x=moveToX,moveToY) : 휠클릭
  • pyautogui.doubleClick(x=moveToX,moveToY) : 더블클릭
  • pyautogui.tripleClick(x=moveToX,moveToY) : 세번클릭
  • pyautogui.scroll(amount_to_scroll,x=moveToX,y=moveToY) : 마우스 스크롤 한다. 양수면 위로, 음수면 아래로
  • pyautogui.mouseDown(x=moveToX, y=moveToY, button='left') : 마우스버튼을 "누른다"
  • pyautogui.mouseUp(x=moveToX, y=moveToY, button='left') : 마우스버튼을 "뗀다"
  • pyautogui.typewrite(type_string, interval=secs_between_keys) : type_string을 친다.
  • pyautogui.hotkey(param1, param2...) : 단축키로 쓰인다. 보통 param에 'ctrl', 'shift'등이 쓰인다.
  • pyautogui.keyDown(key_name) : key_name을 '누른다'
  • pyautogui.keyUp(key_name) : key_name을 '누른다'
  • pyautogui.alert(message) : 경고 메시지 박스
  • pyautogui.confirm(message) : 확인 메시지 박스
  • pyautogui.prompt(message) : user Input 처리를 위한 메시지 박스
  • pyautogui.screenshot(region=(x1,y1,x2,y2)) : 스크린샷을 찍는다. PIL.Image 객체를 반환한다.
  • pyautogui.locateOnScreen(Image_name) : 모니터화면에서 Image_name에 해당하는 Image를 찾아서 위치를 반환한다.(웹 개체는 안된다. 로컬개체만)

이거말고도 pixelMatchsColor등 특정 규칙에 맞게 화면의 마우스를 이동시키는 방법도 있다.

 

출처 : https://pyautogui.readthedocs.io/en/latest/index.html

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

[출처] https://tutoreducto.tistory.com/208

 

 

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
102 [python 인터넷] 초간단 API서버 만들기 - 1부 (Python + Flask + Apache) file 졸리운_곰 2023.01.24 324
101 [python][인터넷] Flask 또는 Django를 Production 서버로 배포(Deploy)하기 file 졸리운_곰 2023.01.17 294
100 [python, 인터넷] Web Search Engine, 인터넷 검색 엔진 구현 file 졸리운_곰 2023.01.16 448
99 [Amazon S3 clone] minio 설치 및 파이썬 업로드 스크립트 졸리운_곰 2022.12.24 254
98 [python 인터넷] Python으로 XML-RPC 서버 구축 file 졸리운_곰 2022.06.28 501
97 [python 인터넷][네이버 뉴스 크롤링] python crawling - 네이버 뉴스 기사 크롤링 file 졸리운_곰 2022.06.28 356
96 [python 인터넷] How to Select CheckBox and Radio Button in Selenium WebDriver 졸리운_곰 2021.11.26 497
95 [python 인터넷] [Python] Selenium 사용하기 (+PhantomJS) file 졸리운_곰 2021.11.26 364
94 [python 인터넷] Python Selenium(셀레니움) 크롬창 활성 탭 변경하기 file 졸리운_곰 2021.11.26 366
93 [python 인터넷 ,selenium] selenium iframe 처리하기 file 졸리운_곰 2021.11.26 541
92 [python 인터넷] Selenium에서 특정 element가 갑자기 클릭이 되지 않을 때 (python) 졸리운_곰 2021.11.26 283
91 [python 인터넷] Selenium Python button 클릭 file 졸리운_곰 2021.11.26 311
90 [python 인터넷] Tor browser 로 selenium webdriver 크롤링 ip 우회 [Windosws] 졸리운_곰 2021.11.26 334
89 [python 인터넷] 파이썬 셀레니움을 이용한 DC인사이드 자동 글쓰기 file 졸리운_곰 2021.11.26 500
88 [Python][Dash] DASH PLOTLY 설치부터 튜토리얼까지 졸리운_곰 2021.09.11 383
87 python - 국가공휴일 데이터 가져오기 (data.go.kr) file 졸리운_곰 2021.09.05 220
86 [python][web] Separate Front-end from Back-end with Flask+AJAX file 졸리운_곰 2021.08.13 267
85 [scrapy] https://pypi.org/project/scrapy-save-as-pdf/ 졸리운_곰 2021.07.03 473
84 Pipeline to Download PDF or Save page as PDF for scrapy item 졸리운_곰 2021.06.26 302
83 [python, 인터넷] [카프카] Python으로 Kafka에 전송(Producer)하고 가져오기(consumer) file 졸리운_곰 2021.06.19 434
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED