매크로

조회 수 345 추천 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
분류 제목 글쓴이 최근변경 추천
질문 PC버전 모비즌 질문입니다. 2 코렐디아 2016.04.10 0/0
질문 PC바람 오토핫키 오픈소스 우회 질문이요. 충주신군 2020.12.26 0/0
질문 pc메이플 사냥 dleogns 2018.09.17 0/0
질문 pc메이플 매크로쓰시는 분들은 키보드 매크로 쓰시나요... 3 열심히해보자요 2020.04.10 0/0
자유 pc메이플 만드시는분 혹시계신가요? 르에 2018.09.17 0/0
질문 pc단풍나무 매크로 질문입니다 2 YOB 2017.07.14 0/0
질문 PC게임에서 사용할 수 있는 매크로 뭐가 있을까요? 6 리세마룽 2018.11.02 0/0
자유 PC게임,특히 린지같은것 매크로하실분들 참고요. 4 우후훅 2015.11.27 0/0
질문 PC 바람의나라 오토핫키 우회법 문의 3 레인슈터 2023.06.20 0/0
질문 pc 메이플 사냥 매크로 라타치야 2018.10.03 0/0
질문 pBitmapHaystack 과 pBitmapNeedle에 대해질문드립니다. 5 walter 2016.02.29 0/0
질문 Pause 명령어가 안먹어요 토오키 2023.02.24 0/0
질문 pastebin 인증이 안되네요.. 도와주세요 ㅠ 3 껨달 2015.02.08 0/0
질문 Page%A_index% := Web.document.getElementsByClassNam... 2 _Crash 2015.09.15 0/0
질문 ova 원클릭 실행 문의 2 GN3 2015.06.19 0/0
질문 OS에서 기본 제공하는 단축키와 오토핫키의 핫키 검정다람쥐 2016.04.17 0/0
질문 OS나 32/64비트 환경에따라 작동여부가 갈리기도하나요? 라미첼 2016.10.26 0/0
정보 OSD정의 및 오토핫키에서의 구현 Allyce 2017.06.08 0/0
질문 or 이런식으로 적용되나요? 1 ziss 2017.11.26 0/0
질문 opencv 템플매칭 ahk로 가능하신분 계신가요? 6 광대승천 2020.08.20 0/0
Board Pagination Prev 1 ... 177178179180181182183184185 ... 209 Next
/ 209

전체 최신 인기글

전체 주간 인기글