#Singleinstance Force
#Include Gdip.ahk
#Include Gdip_ImageSearch.ahk
SetBatchLines, -1
SetWorkingDir, %A_WorkingDir%
;=========================================================함수선언===============================================================
Gdip_ImageSearchWithHwnd(Hwnd,Byref X,Byref Y,Image,Variation=0,Trans="",sX = 0,sY = 0,eX = 0,eY = 0)
{
SysGet, wFrame, 7
SysGet, wCaption, 4
gdipToken := Gdip_Startup()
bmpHaystack := Gdip_BitmapFromHwnd(Hwnd)
bmpNeedle := Gdip_CreateBitmapFromFile(Image)
if( sX!= 0 || sY!= 0 || eX!= 0 || eY != 0)
{
sX := sX + wFrame
sY := sY + wCaption + wFrame
eX := eX + wFrame
eY := eY + wCaption + wFrame
}
RET := Gdip_ImageSearch(bmpHaystack,bmpNeedle,LIST,sX,sY,eX,eY,Variation,Trans,1,1)
Gdip_DisposeImage(bmpHaystack)
Gdip_DisposeImage(bmpNeedle)
Gdip_Shutdown(gdipToken)
StringSplit, LISTArray, LIST, `,
X := LISTArray1 - wFrame
Y := LISTArray2 - wCaption - wFrame
;msgbox, %bmpHaystack%||%bmpNeedle%||%RET%
;GuiControl,,로그, %bmpHaystack%||%bmpNeedle%||%RET%
if(RET = 1)
{
return true
}
else
{
return false
}
}
;이미지 찾을때까지 대기
WaitImage(ByRef clickX, ByRef clickY, ImageName, errorRange, trans, sX = 0, sY = 0, eX = 0, eY = 0)
{
Loop
{
if(IsImagePlus(clickX, clickY, ImageName, errorRange, trans, sX, sY, eX, eY))
{
break
}
Sleep, 500
}
Sleep, 200
Return
}
;이미지 찾을때까지 대기후 클릭
WaitImageclick(ByRef clickX, ByRef clickY, ImageName, errorRange, trans, sX = 0, sY = 0, eX = 0, eY = 0)
{
Loop
{
if(IsImagePlus(clickX, clickY, ImageName, errorRange, trans, sX, sY, eX, eY))
{
click(clickX, clickY)
break
}
Sleep, 500
}
Sleep, 200
Return
}
;이미지찾기
IsImagePlus(ByRef clickX, ByRef clickY, ImageName, errorRange, trans, sX = 0, sY = 0, eX = 0, eY = 0)
{
WinGet, Title , ID, BlueStacks App Player
if(Gdip_ImageSearchWithHwnd(Title, clickX, clickY, ImageName, errorRange, trans, sX, sY, eX, eY))
{
return true
}
else
return false
}
;이미지찾은 후 클릭
IsImagePlusclick(ByRef clickX, ByRef clickY, ImageName, errorRange, trans, sX = 0, sY = 0, eX = 0, eY = 0)
{
WinGet, Title , ID, BlueStacks App Player
if(Gdip_ImageSearchWithHwnd(Title, clickX, clickY, ImageName, errorRange, trans, sX, sY, eX, eY))
{
click(clickX, clickY)
return true
}
else
return false
}
;클릭
;클릭
Click(x, y)
{
sleep, %TIME_REFRESH%
Coor := x | y<<16
WinGet, ActiveID, ID, BlueStacks App Player
if(x = 0 && y = 0)
{
return false
}
if not getkeystate("Ctrl" , "p")
{
PostMessage, 0x201, 0, %Coor%,, ahk_id %ActiveID%
PostMessage, 0x202, 0, %Coor%,, ahk_id %ActiveID%
{
sleep, %TIME_REFRESH%
Coor := x | y<<16
WinGet, ActiveID, ID, BlueStacks App Player
if(x = 0 && y = 0)
{
return false
}
if not getkeystate("Ctrl" , "p")
{
PostMessage, 0x201, 0, %Coor%,, ahk_id %ActiveID%
PostMessage, 0x202, 0, %Coor%,, ahk_id %ActiveID%
sleep, %TIME_REFRESH%
}
else if getkeystate("Ctrl" , "p")
{
Loop
{
if not getkeystate("Ctrl" , "p")
{
PostMessage, 0x201, 0, %Coor%,, ahk_id %ActiveID%
PostMessage, 0x202, 0, %Coor%,, ahk_id %ActiveID%
sleep, %TIME_REFRESH%
break
}
sleep, 100
}
}
}
sleep, %TIME_REFRESH%
}
else if getkeystate("Ctrl" , "p")
{
Loop
{
if not getkeystate("Ctrl" , "p")
{
PostMessage, 0x201, 0, %Coor%,, ahk_id %ActiveID%
PostMessage, 0x202, 0, %Coor%,, ahk_id %ActiveID%
sleep, %TIME_REFRESH%
break
}
sleep, 100
}
}
}
$F2::
MsgBox, 공지창 찾기시작
Loop
{
if (isimageplus(ClickX, ClickY, "image\공지닫기.bmp", 60, 0))
{
MsgBox, 공지창 찾음
click(518, 470)
break
}
else
{
Sleep, 1000
}
}
return
F2키 누르면 공지 이미지를 찾고 좌표를 클릭하고 싶은데 클릭을 못하네요;;;