Code: Select all
;- example shows 4 pictures
;- 3th picture name is wrong so clicks picture-1+2 AND picture-4
;----------------------------------------------------------------------------
#Warn
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode,Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode,Pixel,Screen
CoordMode,Mouse,Screen
;-------------------------------------------------------------
i=0
ur1=https://autohotkey.com/boards/images/flags/russia.png
SplitPath,ur1, name1, dir1, ext, name_no_ext, drive
f1 =%a_scriptdir%\%name1%
ur2=https://autohotkey.com/boards/images/flags/germany.png
SplitPath,ur2, name2, dir2, ext, name_no_ext, drive
f2 =%a_scriptdir%\%name2%
ur3=https://autohotkey.com/boards/images/flags/china.png
SplitPath,ur3, name3, dir3, ext, name_no_ext, drive
f3 =%a_scriptdir%\%name3%
f3a:="" ;- wrong name so search next picture
ur4=https://autohotkey.com/boards/images/flags/france.png
SplitPath,ur4, name4, dir4, ext, name_no_ext, drive
f4 =%a_scriptdir%\%name4%
ifnotexist,%f1%
urldownloadtofile,%ur1%,%f1%
ifnotexist,%f2%
urldownloadtofile,%ur2%,%f2%
ifnotexist,%f3%
urldownloadtofile,%ur3%,%f3%
ifnotexist,%f4%
urldownloadtofile,%ur4%,%f4%
;---------------------------------------------------------------
Gui,add,picture, gA1 x10 y10 ,%f1%
Gui,add,picture, gA2 x90 y10 ,%f2%
Gui,add,picture, gA3 x170 y10 ,%f3%
Gui,add,picture, gA4 x250 y10 ,%f4%
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
a3:
msgbox, 262208, ,Clicked Picture %name3%,2
return
a4:
msgbox, 262208, ,Clicked Picture %name4%,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
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f3a% ;- wrong name for TEST
picx=%name3%
gosub,errorx
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f4%
picx=%name4%
gosub,errorx
msgbox, 262208, ,FINISHED
return
errorx:
i++
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
return
;====================== END script =================================