Code: Select all
;- example downloads 2 picture show in GUI and search them ( Button-F2 )
;- modified=20180201
;-----------------------------------------------------------------------
#warn
setworkingdir,%a_scriptdir%
pic1=https://autohotkey.com/boards/images/flags/spain.png
SplitPath,pic1, name1, dir1, ext, name_no_ext, drive
f1 =%a_scriptdir%\%name1%
urldownloadtofile,%pic1%,%f1%
pic2=https://autohotkey.com/boards/images/flags/portugalbrazil.png
SplitPath,pic2, name2, dir2, ext, name_no_ext, drive
f2 =%a_scriptdir%\%name2%
urldownloadtofile,%pic2%,%f2%
Gui,add,picture, gA1 x10 y10 ,%f1%
Gui,add,picture, gA2 x90 y10 ,%f2%
gui,show, x100 y10 h70 w300 ,Use F2 to search Picture
return
;-------------
guiclose:
exitapp
;-------------
a1:
msgbox, 262208, ,Clicked Picture %name1%,2
return
a2:
msgbox, 262208, ,Clicked Picture %name2%,2
return
;----------------------------------------------------------------------
$F2::
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f1%
picx=%name1%
gosub,errorx
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f2%
picx=%name2%
gosub,errorx
msgbox, 262208, ,FINISHED
return
errorx:
if errorlevel=1
{
msgbox, 262208, ,Error`nTry with next picture in 3 seconds,3
return
}
else if errorlevel=2
{
msgbox, 262208, ,Picture %picx% not found`nNow continue in 3 seconds with next-picture,3
return
}
MouseMove,%xf%,%yf%,
ToolTip,Here is the picture %picx%
sleep,2500
tooltip
MouseClick,left,%xf%,%yf% ;- click on x-picture
sleep,1000
return
;====================== END script =================================