a:=PicWaitAndClick("pic1.png")
MsgBox, % a
ExitApp
PicWaitAndClick(picture, click:=1,dx := 0,dy := 0, PreClickDelay := 0,break_index := 1,Loop_Sleep := 20)
{
Loop
{
ImageSearch, x, y, 0, 0,% A_ScreenWidth,% A_ScreenHeight, % picture
if errorlevel=0
break
if a_index=%break_index%
return 0
sleep % Loop_Sleep
}
if PreClickDelay!=0
Sleep % PreClickDelay
if click=1
MouseClick,left,% x+dx,% y+dy
else
MouseMove, % x+dx,% y+dy
return 1
}
#Include C:\Program Files\AutoHotkey\lib\Gdip.ahk
IniRead,indx,scrn_indx.ini,indx,indx,0
indx++
CoordMode,mouse,screen
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
w:=A_ScreenWidth
h:=A_ScreenHeight
pBrush:=Gdip_BrushCreateSolid("0x220000ff")
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA
hwnd1 := WinExist()
hbm := CreateDIBSection(w, h)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 5)
pBitmap:=Gdip_BitmapFromScreen()
Gdip_DrawImage(G, pBitmap, 0, 0, w, h, 0, 0, w, h)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, w, h)
Hotkey,LButton,return
KeyWait,LButton,d
MouseGetPos,M1X,M1Y
while GetKeyState("LButton","P")
{
MouseGetPos,M2X,M2Y
Gdip_DrawImage(G, pBitmap, 0, 0, w, h, 0, 0, w, h)
Gdip_FillRectangle(G, pBrush, min(M1X,M2X), min(M1Y,M2Y), abs(M2X-M1X), abs(M2Y-M1Y))
UpdateLayeredWindow(hwnd1, hdc, 0, 0, w, h)
}
Gdip_DrawImage(G, pBitmap, 0, 0, w, h, 0, 0, w, h)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, w, h)
pBitmap:=Gdip_BitmapFromScreen(min(M1X,M2X) "|" min(M1Y,M2Y) "|" abs(M2X-M1X) "|" abs(M2Y-M1Y) )
Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir "\my_pic_" indx ".png", 100)
IniWrite,%indx%,scrn_indx.ini,indx,indx
ToolTip Done
sleep 100
Reload
max(a,b)
{
if a>%b%
return a
return b
}
min(a,b)
{
if a<%b%
return a
return b
}
return:
return
Esc::
Exit:
Gdip_Shutdown(pToken)
ExitApp