Skip to content
조회 수 4084 추천 수 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
번호 분류 제목 날짜 조회 수
897 AutoHotKey ahk) Send an email 메일발송하기 2018.01.17 9439
896 AutoHotKey AHK) 보안프로그램 등으로 화면복사(Printscreen) 안될때 사용방법 1 12 file 2012.11.21 47172
895 AutoHotKey ahk) 열려진 엑셀창의 값 불러오기 1 2013.10.30 32537
894 AutoHotKey ahk) 오토핫키 콤보박스 제어하기 file 2013.10.30 38183
893 AutoHotKey Ahk) 웹페이지 감시결과에 따라 마이피플로 글 전송하기 12 file 2013.01.06 44025
892 AutoHotKey ahk_l 웹페이지 앞, 뒤페이지 제어 예제소스 및 설명첨부 2011.02.22 17536
891 AutoHotKey ahk_l 과 com 의 이해 2011.02.22 17486
890 AutoHotKey AHK_L 예제소스 1 2011.02.10 17020
889 AutoHotKey ahk_l 웹페이지 파일로 저장한 뒤 불러와 필요한 부분 추출하여 출력하기 2011.02.22 16992
888 컴퓨터잡담 AHK_L) SysListView321 컨트롤 내용 추출하기 2011.10.07 9893
887 AutoHotKey ahk로 만든 파일을 exe로 컴파일 한 후 실행시킬때 변수를 임의 1 1 2011.02.24 15333
886 AutoHotKey AHK에서 가능한 COM 인터넷 익스플로러 및 GUI 브라우저 1 2011.02.11 19502
885 AutoHotKey ahk와 ahk_l 의 웹페이지 로딩완료 체크 비교 3 2011.02.11 20325
884 컴퓨터잡담 ajax의 XMLHttpRequest 객체 1 2010.03.27 7463
883 WindowsTip An error [-5001 : 0x80070002] ha occurred while running the setup 오류 해결방법 file 2013.06.14 21945
882 Server Apache & Mysql 셋팅방법(httpd-mpm.conf / my.ini) 2013.05.13 13709
881 Server APACHE PHP 에러 잡기 1 2016.03.23 9996
880 Server Apache에 대한 mod_proxy 지원 구성 2016.09.06 1801
879 컴퓨터잡담 API Hooking 유저 레벨 루트킷 1 2010.01.21 11623
878 Server APMSETUP7 PHP 업그레이드 2015.06.02 6373
Board Pagination Prev 1 2 3 4 5 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소