Code: Select all
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=26342&p=123836#p123836 ---
;- example shows 4 pictures / open https://www.autohotkey.com/boards/
;- maybe add f1a / f3a to 1st and 3th picture name is then wrong so clicks picture-2 AND picture-4
;----------------------------------------------------------------------------
#Warn
#NoEnv
SendMode,Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode,2
SetBatchLines, -1
FileEncoding, UTF-8
Gui,2:default
GUI,2:+AlwaysOnTop
Gui,2: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,2:Font,s14 ,Lucida console
Gui,2:Color,Black
Gui,2:Color, ControlColor, Black
wa:=A_screenwidth
ha:=A_screenHeight
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%
f1a:="" ;- wrong name so search next picture
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,2:add,picture, gA1 x10 y10 ,%f1%
Gui,2:add,picture, gA2 x90 y10 ,%f2%
Gui,2:add,picture, gA3 x170 y10 ,%f3%
Gui,2:add,picture, gA4 x250 y10 ,%f4%
gui,2:show, x100 y10 h70 w500 ,F2 to start
return
2guiclose:
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,500,200,*transblack %f1% ;- maybe add wrong name for TEST f1a
picx=%name1%
gosub,errorx
ImageSearch,xf,yf,0,0,500,200,*transblack %f2%
picx=%name2%
gosub,errorx
ImageSearch,xf,yf,0,0,%wa%,%ha%,*transblack %f3a% ;- maybe add wrong name for TEST f3a
picx=%name3%
gosub,errorx
ImageSearch,xf,yf,0,0,%wa%,%ha%,*transblack %f4%
picx=%name4%
gosub,errorx
mousemove,1,1
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 =================================