Skip to content
조회 수 4047 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

파이썬 비활성화 창 이미지 캡쳐하고 클릭하기

 

참고사이트

  1. https://tone.tistory.com/120
  2. https://lemon7z.tistory.com/72
  3. https://mandloh.tistory.com/126
  4. https://mandloh.tistory.com/79

 

 


Requirements

1. 파이썬 라이브러리 설치

pip install pywin32

 

 


#https://tone.tistory.com/120

#비활성 창의 이미지 추출

 

#-*-coding:utf-8  

#한글 입력을 위한 정의

 

import win32gui 

import win32ui

#윈도우 핸들을 찾기 위한 라이브러리

#pip install pypiwin32

#anconda환경이라면 conda install -c anaconda pywin32

from PIL import Image

#이미지저장을 위한 라이브러리

#pip install pillow

 

from ctypes import windll

#윈도우 dll사용을 위한 라이브러리

 

hwndname ='NoxPlayer3'

hwnd = win32gui.FindWindow(None, hwndname)

if hwnd >=1:

    left, top, right, bot = win32gui.GetWindowRect(hwnd)

    w = right - left

    h = bot - top

    hwndDC = win32gui.GetWindowDC(hwnd)

    mfcDC  = win32ui.CreateDCFromHandle(hwndDC)

    saveDC = mfcDC.CreateCompatibleDC()

 

    saveBitMap = win32ui.CreateBitmap()

    saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)

 

    saveDC.SelectObject(saveBitMap)

 

    result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 0)

 

    bmpinfo = saveBitMap.GetInfo()

    bmpstr = saveBitMap.GetBitmapBits(True)

    im = Image.frombuffer('RGB',(bmpinfo['bmWidth'], bmpinfo['bmHeight']), bmpstr, 'raw', 'BGRX', 0, 1)

    win32gui.DeleteObject(saveBitMap.GetHandle())

    saveDC.DeleteDC()

    mfcDC.DeleteDC()

    win32gui.ReleaseDC(hwnd, hwndDC)

    

if result ==1: 

    #성공적으로 윈도우 값을 가져왔다면

    im.save("test.png")

    #이미지저장

 

비활성 클릭 코드

import win32api
import win32gui
import win32con


def click(x, y):
    hWnd = win32gui.FindWindow(None, "글쓰기 - Mozilla Firefox")
    lParam = win32api.MAKELONG(x, y)

    hWnd1 = win32gui.FindWindowEx(hWnd, None, None, None)
    win32gui.SendMessage(hWnd1, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam)
    win32gui.SendMessage(hWnd1, win32con.WM_LBUTTONUP, None, lParam)


if __name__ == '__main__':
    click(100,200

 


 

 

 

 

로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
77 컴퓨터잡담 파이썬 웹페이지 기업정보 추출하기 2021.06.02 1823
76 Server xe 타이틀 게시판 이름 없애기 file 2016.06.28 1803
75 Server Apache에 대한 mod_proxy 지원 구성 2016.09.06 1801
74 컴퓨터잡담 KM Wakeup 절전모드 예약 및 깨우는 프로그램 file 2021.07.08 1784
73 컴퓨터잡담 파이썬 사이트 정보 가져와서 필요한 내용 추출하기 2021.05.31 1780
72 WindowsTip 컴퓨터가 많이 느리다면? 2015.01.08 1777
71 WindowsTip 윈도우 XP SP3 와 Windows 8.1 두가지 부팅 메뉴얼 file 2015.02.11 1768
70 파이썬 키움증권 OpenAPI 당황스러움 file 2021.09.06 1750
69 Server 서버 부하상태 체크 file 2016.04.30 1709
68 컴퓨터잡담 파이썬 리스트에 데이터 삽입하기 2021.06.22 1707
67 [Docs]스프레드시트 스프레드시트의 값의 변화에 따라 지메일로 메일을 보내는 스크립트 2023.03.10 1661
66 WindowsTip 익스플로러 ftp 정상화 시키기 file 2014.12.23 1660
65 Server [Apache] mod_expires .htaccess을 수정하여 브라우저 캐싱하기 2016.03.16 1658
64 Server XE file cache 활용 2016.08.19 1648
63 WindowsTip IE 익스플로러 메뉴 바탕이 검정색으로 변했을경우 대처방법 2 2015.01.27 1644
62 Server [아파치 error.log] Fatal Error Unable to reattach to base address file 2016.03.25 1643
61 컴퓨터잡담 파이썬 멀티라벨 소스 줄이기 2021.06.23 1634
60 컴퓨터잡담 파이썬 한우정액 정보 스프레드로 추출하기 file 2021.06.05 1625
59 컴퓨터잡담 Python 파일을 exe파일로 컴파일하기 2021.06.16 1611
58 컴퓨터잡담 [python] 윈도우 파이썬 모듈 설치 방법 (특정프로그램 설치 없이 기본프로그램 활용) 2021.09.02 1589
Board Pagination Prev 1 ... 41 42 43 44 45 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소