Code: Select all
;- Нужна помощь! Помогите со скриптом
;- https://www.autohotkey.com/boards/viewtopic.php?f=52&t=103542&p=460293#p460293
;- modified = 20220504
;- created = 20220503
;- changes picture position and click on color ED1313 ifwinactive GUI
;- example needs 2 pictures for test , 1 picture contains color ED1313
;-
#Warn
#NoEnv
setworkingdir, %a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
Gui,2:Color,black
Gui,2:Font, S10 CDefault , Lucida Console
global pic1,pic2,pic3,pic4
;--
P1:=a_scriptdir . "\ED1313_01.png" ;- save it from here > https://prnt.sc/FBWSIqhoHmjF picture contains color ED1313
P2:=a_scriptdir . "\ru.png" ;- picture not contains the color ED1313
NE:=a_scriptdir . "\ED1313_NE.png" ;- not existing picture
SplitPath,P1, name, dir, ext, name_no_ext, drive
;--
xx:=100, i:=0,WA:=A_screenwidth,HA:=A_screenheight,PW:=(WA*9)/xx
X1:=(WA*1 )/xx ,Y1:=(HA*1 )/xx
X2:=(WA*10)/xx ,Y2:=(HA*1 )/xx
X3:=(WA*1 )/xx ,Y3:=(HA*10)/xx
X4:=(WA*10)/xx ,Y4:=(HA*10)/xx
xt:=(WA*1 )/xx ,yt:=(HA*24)/xx,xt2:=(WA*1)/xx ,yt2:=(HA*27)/xx,wt2:=(wa*10)/xx
gx:=(WA*20)/xx ,gy:=(ha*10)/xx,gw:=(wa*30)/xx, gh:=(ha*30)/xx ;- GUI
;--
goto,case2 ;- search SCREEN
CASE1:
Coordmode,Pixel,Relative
Coordmode,Mouse,Relative
x11:=(WA*0)/xx,y11:=(HA*0)/xx,x21:=GW,y21:=GH ;- area Pixelsearch GUI ( Coordmode Relative )
goto,continue
CASE2:
Coordmode,Pixel,Screen
Coordmode,Mouse,Screen
x11:=gx,y11:=gy,x21:=gx+GW,y21:=gy+GH ;- area Pixelsearch SCREEN ( Coordmode screen )
continue:
color=0xED1313
;--
gui,2:add,picture, x%X1% y%Y1% w%PW% h-1 vPIC1 ,%P1%
gui,2:add,picture, x%X2% y%Y2% w%PW% h-1 vPIC2 ,%P1%
gui,2:add,picture, x%X3% y%Y3% w%PW% h-1 vPIC3 ,%P1%
gui,2:add,picture, x%X4% y%Y4% w%PW% h-1 vPIC4 ,%P1%
gui,2:add,text,x%xt% y%yt% cyellow,use LSHIFT to search COLOR ED1313
gui,2:add,text,x%xt2% y%yt2% w%wt2% cyellow vT2,
gui,2:show,x%gx% y%gy% h%GH% w%GW%,TEST PixelSearch
settimer,a1,1500 ;- change picture position
gosub,a1
mousemove,0,0,0
return
;---------
2Guiclose:
exitapp
;----------------------
A1:
Gui,2:submit,nohide
loop,4
GuiControl,2:, Pic%a_index%,%NE% ;- remove pictures
i++
if (i=5)
i:=1
if (i=2)
GuiControl,2:,PIC%I%,%p2%
else
GuiControl,2:,PIC%I%,%p1%
return
;----------------------
#IfWinActive TEST PixelSearch
~LShift::
While GetKeyState("LShift", "P")
{
PixelSearch, XF, YF, X11, Y11, X21, Y21,color, 0, RGB Fast
If (!ErrorLevel)
{
MouseClick,left,%xf%,%yf%,,0
;tooltip,HERE is COLOR=%color% %name%
ToolTip,-- найден %color% цвет
}
Else
{
;tooltip,NOT FOUND %color%
tooltip,## Не найден %color% цвет
;msgbox, 262208, , Не найден %Color% цвет,3
}
}
tooltip
return
;=============================================================