Skip to content
조회 수 4049 추천 수 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
번호 분류 제목 날짜 조회 수
36 파이썬 파이썬 변수내용 문자열 자르기 특이한 점 2021.09.27 2965
35 파이썬 python html tag 제거 경로 금지 문자 제거 2021.10.26 3199
34 파이썬 파이썬 정규표현식 (Regular Expressions) 2021.10.31 3199
33 파이썬 pytube 사용방법 2022.01.22 4191
32 파이썬 파이썬 ModuleNotFoundError: No module named 'pip' 갑자기 나타난 오류! 2022.02.13 4108
31 파이썬 Visual Studio Code 파이썬 인터프리터 경로 변경하기 2022.03.09 9288
30 파이썬 파이썬 googleapiclient 모듈이 설치가 안될때 해결방법 1 2022.03.27 9874
29 파이썬 파이썬 구글스프레드시트 값 불러오기 html로 변환작업 중! 2022.05.08 20186
28 파이썬 파이썬 파이인스톨러 설치하기 2022.05.08 21421
27 파이썬 자바스크립트 종말각?! HTML에서 파이썬 실행하는 PyScript 등장! 2022.06.08 31364
26 파이썬 파이썬 글자 인식, 파이썬 OCR, 파이썬 Tesseract 사용 2022.11.21 14641
25 파이썬 Windows용 Tesseract 설치 및 사용법 2022.11.26 19534
24 파이썬 파이썬 화면 캡쳐하기 2022.11.26 19343
23 파이썬 파이썬을 이용하여 매크로 만들기 2023.01.13 9238
22 파이썬 파이썬 easyocr 이미지 문자 인식 2023.01.16 10314
21 파이썬 chatGPT file 2023.02.11 4399
20 파이썬 파이썬 pyautogui 화면에 여러개의 동일한 이미지가 있을 때 n번째 이미지 선택하기 2023.02.12 5044
19 파이썬 파이썬 pyautogui 자주쓰는 이미지 서치 def 지정하기 2023.02.12 5259
18 파이썬 파이썬 모듈 업그레이드 명령어 2023.02.21 3629
» 파이썬 파이썬 비활성화 창 이미지 캡쳐하고 클릭하기 2023.02.24 4049
Board Pagination Prev 1 2 3 Next
/ 3

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소