Skip to content
조회 수 4076 추천 수 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
번호 분류 제목 날짜 조회 수
917 AutoHotKey #ifwinactive & #ifwinexist 윈도우창 마다 핫키의 용도를 다르게 사용하는 방법 2011.02.14 16526
916 Excel 'C:Documents.xlsx' 을(를) 찾을 수 없습니다. 라는 오류 메시지가 나오는 경우 대처방법 2015.01.28 4789
915 WindowsTip (nPDF) 프린터 인쇄 내용을 PDF 파일로 변환하기 2015.01.24 2273
914 컴퓨터잡담 -응답없음- 으로 멈춰버린 프로그램 대기시간 줄이는 방법 2010.10.01 7866
913 컴퓨터잡담 .htaccess와 워터마킹을 이용한 이미지 링크 방지 2009.06.30 34918
912 WindowsTip 100M Full 속도내기(레지스터리) file 2013.01.11 6528
911 컴퓨터잡담 16진수 헥사, 2진수, 10진수, 8진법 변환 계산기; Hex Calc 2012.02.22 7917
910 컴퓨터잡담 2021년 플래시 플레이어 웹사이트 크롬에서 접속하는 방법 2021.07.05 2561
909 컴퓨터잡담 2023-09-23 서버다운 후 복구완료 secret 2023.09.23 49728
908 컴퓨터잡담 50 개 이상의 Ajax 예제들 2 2010.03.29 18950
907 컴퓨터잡담 50 개 이상의 Ajax 예제들 2010.03.29 18179
906 Server 8기가 램에 맞는 Mysql config 셋팅 값 1 2016.02.22 3859
905 컴퓨터잡담 ACTIVE-X 의 무서움 file 2015.12.26 669
904 컴퓨터잡담 AHK & my Address of Pointer and my Offset 2011.10.11 13184
903 컴퓨터잡담 Ahk Standard Library Collection, 2010 Sep (+Gui) ~ Libs: 100 3 2011.10.11 14190
902 AutoHotKey ahk) autohotkey controlgettext 이름을 마우스커서에 졸졸 따라다니게 하기 file 2014.04.01 12232
901 AutoHotKey ahk) autohotkey 글자 자르기 방법 2013.10.30 34676
900 AutoHotKey ahk) autohotkey 엑셀(Excel)에서 행값 증가시키기 2013.10.30 37423
899 AutoHotKey AHK) AUTOKEY 웹페이지 열지않고 소스 가져오기 또는 로그인 하기 14 2012.05.12 52958
898 AutoHotKey Ahk) ip할당 진단프로그램 file 2011.12.26 12122
Board Pagination Prev 1 2 3 4 5 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소