매크로

조회 수 361 추천 0 댓글 5


 비활성이미지서치와 비활성클릭을 위한 좌표까지 얻어내는데 성공하였습니다.

  하지만 pBitmapHaystack 과 pBitmapNeedle 

         숨겨진창 비활성화된 창의 이미지 와 이미지 파일로부터 가져온 이미지가 

  서로 일치하지 않을때도 비활성클릭을 이상한데로 하게되는데요.


    2개의 이미지가 서로 일치하는 부분이 없을때는 비활성 클릭을 하지 않으려면

  어떤 부분을 건드려봐야할지 조언 부탁드립니다.


2,3달 가량 이미지 찾는것도 안되다가 오늘 좌표까지 나오게 되면서 약간 욕심부려서 해보고있습니다.

제가 매우 부족한점이 많지만 이거 한번 성공해 보고싶네요.


  • 로뎀나무 2016.02.25 08:29

    소스를 좀 올려주셔야 확인이 가능할텐데요;;

  • walter 2016.02.28 15:28
    F2::
    WinGet, Title , ID, BlueStacks App Player ; 핸들값을 얻어온다

    Gdip_ImageSearchWithHwnd(Title,"1.png",X,Y,80) ; 이미지서치
    msgbox % X Y 
    클릭(X,Y)
    return
    ;===================================================

    Gdip_ImageSearchWithHwnd(Hwnd,Image,Byref X,Byref Y,Variation=0,Trans="")
    {
    gdipToken := Gdip_Startup()
    bmpHaystack := Gdip_BitmapFromHwnd(Hwnd)
    bmpNeedle := Gdip_CreateBitmapFromFile(Image)
    RET := Gdip_ImageSearch(bmpHaystack,bmpNeedle,LIST,0,0,0,0,Variation,Trans,1,1)
    Gdip_DisposeImage(bmpHaystack)
    Gdip_DisposeImage(bmpNeedle)
    Gdip_Shutdown(gdipToken)
    StringSplit, LISTArray, LIST, `,
    X := LISTArray1
    Y := LISTArray2

    }


    클릭(X,Y)
    {

               coordMode, Mouse, clint
      wingetpos,w_x, w_y, w_w, w_h, BlueStacks App Player
      
      내부좌표x := X
      내부좌표y := Y - 24
      
      lparam := 내부좌표x|내부좌표y <<16
      postMessage,0x201,1, %lparam%,, BlueStacks App Player
      PostMessage, 0x202,0, %lparam%,,BlueStacks App Player
      sleep,1000
    }
    ;**********************************************************************************
    ;
    ; Gdip_ImageSearch()
    ; by MasterFocus - 02/APRIL/2013 00:30h BRT
    ; Thanks to guest3456 for helping me ponder some ideas
    ; Requires GDIP, Gdip_SetBitmapTransColor() and Gdip_MultiLockedBitsSearch()
    ; http://www.autohotkey.com/board/topic/71100-gdip-imagesearch/
    ;
    ; Licensed under CC BY-SA 3.0 -> http://creativecommons.org/licenses/by-sa/3.0/
    ; I waive compliance with the "Share Alike" condition of the license EXCLUSIVELY
    ; for these users: tic , Rseding91 , guest3456
    ;
    ;==================================================================================
    ;
    ; This function searches for pBitmapNeedle within pBitmapHaystack
    ; The returned value is the number of instances found (negative = error)
    ;
    ; ++ PARAMETERS ++
    ;
    ; pBitmapHaystack and pBitmapNeedle
    ;   Self-explanatory bitmap pointers, are the only required parameters
    ;
    ; OutputList
    ;   ByRef variable to store the list of coordinates where a match was found
    ;
    ; OuterX1, OuterY1, OuterX2, OuterY2
    ;   Equivalent to ImageSearch's X1,Y1,X2,Y2
    ;   Default: 0 for all (which searches the whole haystack area)
    ;
    ; Variation
    ;   Just like ImageSearch, a value from 0 to 255
    ;   Default: 0
    ;
    ; Trans
    ;   Needle RGB transparent color, should be a numerical value from 0 to 0xFFFFFF
    ;   Default: blank (does not use transparency)
    ;
    ; SearchDirection
    ;   Haystack search direction
    ;     Vertical preference:
    ;       1 = top->left->right->bottom [default]
    ;       2 = bottom->left->right->top
    ;       3 = bottom->right->left->top
    ;       4 = top->right->left->bottom
    ;     Horizontal preference:
    ;       5 = left->top->bottom->right
    ;       6 = left->bottom->top->right
    ;       7 = right->bottom->top->left
    ;       8 = right->top->bottom->left
    ;
    ; Instances
    ;   Maximum number of instances to find when searching (0 = find all)
    ;   Default: 1 (stops after one match is found)
    ;
    ; LineDelim and CoordDelim
    ;   Outer and inner delimiters for the list of coordinates (OutputList)
    ;   Defaults: "`n" and ","
    ;
    ; ++ RETURN VALUES ++
    ;
    ; -1001 ==> invalid haystack and/or needle bitmap pointer
    ; -1002 ==> invalid variation value
    ; -1003 ==> X1 and Y1 cannot be negative
    ; -1004 ==> unable to lock haystack bitmap bits
    ; -1005 ==> unable to lock needle bitmap bits
    ; any non-negative value ==> the number of instances found
    ;
    ;==================================================================================
    ;
    ;**********************************************************************************

    Gdip_ImageSearch(pBitmapHaystack,pBitmapNeedle,ByRef OutputList=""
    ,OuterX1=0,OuterY1=0,OuterX2=0,OuterY2=0,Variation=0,Trans=""
    ,SearchDirection=1,Instances=1,LineDelim="`n",CoordDelim=",") {

        ; Some validations that can be done before proceeding any further
        If !( pBitmapHaystack && pBitmapNeedle )
            Return -1001
        If Variation not between 0 and 255
            return -1002
        If ( ( OuterX1 < 0 ) || ( OuterY1 < 0 ) )
            return -1003
        If SearchDirection not between 1 and 8
            SearchDirection := 1
        If ( Instances < 0 )
            Instances := 0

        ; Getting the dimensions and locking the bits [haystack]
        Gdip_GetImageDimensions(pBitmapHaystack,hWidth,hHeight)
        ; Last parameter being 1 says the LockMode flag is "READ only"
        If Gdip_LockBits(pBitmapHaystack,0,0,hWidth,hHeight,hStride,hScan,hBitmapData,1)
        OR !(hWidth := NumGet(hBitmapData,0))
        OR !(hHeight := NumGet(hBitmapData,4))
            Return -1004

        ; Careful! From this point on, we must do the following before returning:
        ; - unlock haystack bits

        ; Getting the dimensions and locking the bits [needle]
        Gdip_GetImageDimensions(pBitmapNeedle,nWidth,nHeight)
        ; If Trans is correctly specified, create a backup of the original needle bitmap
        ; and modify the current one, setting the desired color as transparent.
        ; Also, since a copy is created, we must remember to dispose the new bitmap later.
        ; This whole thing has to be done before locking the bits.
        If Trans between 0 and 0xFFFFFF
        {
            pOriginalBmpNeedle := pBitmapNeedle
            pBitmapNeedle := Gdip_CloneBitmapArea(pOriginalBmpNeedle,0,0,nWidth,nHeight)
            Gdip_SetBitmapTransColor(pBitmapNeedle,Trans)
            DumpCurrentNeedle := true
        }

        ; Careful! From this point on, we must do the following before returning:
        ; - unlock haystack bits
        ; - dispose current needle bitmap (if necessary)

        If Gdip_LockBits(pBitmapNeedle,0,0,nWidth,nHeight,nStride,nScan,nBitmapData)
        OR !(nWidth := NumGet(nBitmapData,0))
        OR !(nHeight := NumGet(nBitmapData,4))
        {
            If ( DumpCurrentNeedle )
                Gdip_DisposeImage(pBitmapNeedle)
            Gdip_UnlockBits(pBitmapHaystack,hBitmapData)
            Return -1005
        }
        
        ; Careful! From this point on, we must do the following before returning:
        ; - unlock haystack bits
        ; - unlock needle bits
        ; - dispose current needle bitmap (if necessary)

        ; Adjust the search box. "OuterX2,OuterY2" will be the last pixel evaluated
        ; as possibly matching with the needle's first pixel. So, we must avoid going
        ; beyond this maximum final coordinate.
        OuterX2 := ( !OuterX2 ? hWidth-nWidth+1 : OuterX2-nWidth+1 )
        OuterY2 := ( !OuterY2 ? hHeight-nHeight+1 : OuterY2-nHeight+1 )

        OutputCount := Gdip_MultiLockedBitsSearch(hStride,hScan,hWidth,hHeight
        ,nStride,nScan,nWidth,nHeight,OutputList,OuterX1,OuterY1,OuterX2,OuterY2
        ,Variation,SearchDirection,Instances,LineDelim,CoordDelim)

        Gdip_UnlockBits(pBitmapHaystack,hBitmapData)
        Gdip_UnlockBits(pBitmapNeedle,nBitmapData)
        If ( DumpCurrentNeedle )
            Gdip_DisposeImage(pBitmapNeedle)

        Return OutputCount
    }
  • walter 2016.02.28 15:31

    지금 댓글로 올린 소스가 제가 현재 이용해본 소스입니다.

      혹시 질문 답변에 필요하신게 더 있으시다면 알려주시면 추가하여 올리도록 하겠습니다 ^~^

     댓글 달아주셔서 감사합니다.


     If 문을 어떻게 작성해야 블루스택화면 이미지와 이미지파일의 이미지를 비교시에

    서로 일치할때만 클릭하게 할수있을까요?

       아직 If 문을 추가 못하여서 서로 같은 이미지가 블루스택 화면내에 없을때도 

     클라이언트 좌표로 21,21 정도의 부분을 클릭을 하게됩니다.

  • 로뎀나무 2016.02.29 17:00
    Gdip_ImageSearchWithHwnd(Title,"1.png",X,Y,80) ; 이미지서치
    msgbox % X Y ; 여기서 이미지를 찾았나 못찾았나 확인 가능하시죠?
    if (x!="") ; 이미지를 못찾았다면 x값이 없을꺼예요 x값이 있다면
    클릭(X,Y)

    이렇게만 바꿔주셔도 됩니다.

    지금 스크립트에는 분기점이 없죠.. 이미지를 찾았을 경우와 그렇지 않은경우를 확인하는 스크립트가 없어요;
    그것만추가해주시면 됩니다.
  • walter 2016.02.29 21:44
    그러게요 스크립트에 찾았을경우와 그렇지 않을경우에 대한 스크립트가 없더라구요...
    감사합니다 메시지박스 밑에 if문 추가하고 메시지박스는 작동 실험용으로 따로 만들어두고
    실제로 쓰는건 지우면 되겠군요.
    저번에 비활성 이미치 서치 소스 올려놓으신 글도 보았습니다 ㅎ
    답변 달아주셔서 정말 감사합니다 ^^

List of Articles
분류 제목 글쓴이 최근변경 추천
질문 gdip로 클립보드까지 저장은 하였습니다. 4 walter 2016.02.23 0/0
질문 블루스택에서는 gdip로 이미지서치가 가능한가요? 4 walter 2016.02.28 0/0
질문 pBitmapHaystack 과 pBitmapNeedle에 대해질문드립니다. 5 walter 2016.02.29 0/0
질문 이미지 서치 관련 질문 드려요. 4 뎅뎅 2016.02.24 0/0
정보 오랫만에 들러서 하나 투척하고 가요 ^^ 7 로뎀나무 2019.07.30 0/0
질문 이미지 서치 랜덤위치 때문에 질문드립니다. 4 뎅뎅 2016.02.26 0/0
질문 scite4autohotkey 기능 질문드려요 쵸쵸 2016.02.25 0/0
질문 ini파일에 저장이 정상적으로 이루어 졌는지 확인하는... 1 퉁군 2016.03.04 0/0
질문 이런 채팅 매크로 오토핫키(혹은 다른 매크로)로 만들 ... 드링크 2016.02.26 0/0
질문 스크립트 실행시 중복으로 실행못하게 하는 명령어가 뭐죠 1 지니블렉션 2016.02.27 0/0
질문 윈도우 or 구이 비활성화 질문... 4 화프 2016.02.28 0/0
질문 오토핫키파일우클릭 - 속성 - 자세히 여기에 나오는거 ... cjh71 2016.02.28 0/0
질문 핫키 고수님들 ㅠ 변수비교하는데 비교가안되서 도움요... 2 개멍멍멍 2016.03.01 0/0
질문 듀얼모니터 이미지서치 방법좀요 1 사군자vv 2016.03.04 0/0
질문 OCR 과 이미지서치 문제가 안풀립니다.. 6 뎅뎅 2016.03.06 0/0
질문 특정위치 클릭 방법 질문 드리겠습니다. 5 까스배달소년 2016.03.29 0/0
질문 블루스택에서 ESC키 입력하는 법 질문드립니다. 2 amoure 2016.03.04 0/0
질문 gdip 범위지정서치 질문합니다. 8 N4N2 2017.09.07 0/0
질문 메이플매크로/인식이안되도 스크립이 진행되는문제 2 세나블텍 2016.03.04 0/0
질문 원클릭 블루스택 해상도 설정 방법 4 파랑상 2016.03.12 0/0
Board Pagination Prev 1 ... 707172737475767778 ... 209 Next
/ 209

전체 최신 인기글

전체 주간 인기글