#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <file.au3>
$hGui = GUICreate("找图片", 200, 150)
$pathpic=FileOpenDialog("你要找的图片",@DesktopCommonDir, "Images (*.jpg;*.bmp;*.png)", 1 + 4 )
$start=GUICtrlCreateButton("开始找图",70,100)
GUISetState(@SW_SHOW)
Dim $AccelKeys[1][2]=[["{enter}",$start]]
GUISetAccelerators($AccelKeys)
While 1
$MSG=GUIGetMsg()
Switch $MSG
Case $GUI_EVENT_CLOSE
Exit
Case $start
start()
EndSwitch
WEnd
Func start()
Dim $x=0,$y=0
$result = _ImageSearch($pathpic,1,$x,$y,0)
if $result=1 Then
ToolTip("美女你要找的图片是这个不?",$x,$y,"提示",2,1)
Else
MsgBox(16,"提示","没有发现目标")
EndIf
EndFunc
Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
EndFunc
Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
if $result[0]="0" then return 0
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
如果想要命令就可以把它变成一个函数调用
其实不建议用找色,找色不稳定且很多游戏动作不能达到效果,最好是用_MemoryOpen,_MemoryRead,找内存基址,在配合找色。