Code: Select all
#SingleInstance Ignore
#NoEnv
#KeyHistory 0
#Include FindClick.ahk
#Include D:\CL\FindText.ahk
#Include *i Gdip_All.ahk
#Include Gdip_ImageSearch.ahk
ListVars On
$a:: ; Auto Skill
{
CoordMode, Mouse, Window
WinGetPos, sX, sY, sW, sH, ahk_exe Game.exe
if (sW >= 1366) {
Ycp := 30
} else if (sW < 1366) {
Ycp := 56
}
ToolTip, Auto Skill Active, 155, 5, 1
FindClick(A_ScriptDir "\CP.png", "Silent1 Stay1 n0 CEnter0 r x14 y-4", Xfb, Yfb)
Xfb -= sX
Yfb -= sY
loop {
if FindClick("Enemy HP Bar.png","Silent1 Stay1 n0 r a0," Ycp ",,30",Xhp) {
if (sW >= 1366) {
Xhp := Xhp+112
} else if (sW < 1366) {
Xhp := 54+(sW//2)
}
if FindClick("*0xEA39A6","FuncGivePain Silent1 Stay1 e1 r a" Xhp "," Ycp ",10,30") {
} else if FindClick("*0x320F24","FuncFindSkill Silent1 Stay1 e1 r a" Xhp "," Ycp ",10,30") {
}
}
}
}
return
GivePain() {
send, 1
}
AddConf() {
oText := ""
if FileExist("SkillList.txt") {
file := FileOpen("SkillList.txt", "r")
LoadedText := file.Read()
file.Close()
sort, LoadedText, u
; string := RegExReplace(LoadedText,"`am)(.*)\R+$","$1")
FileDelete, % A_ScriptDir "\SkillList.txt"
file := FileOpen("SkillList.txt", "w")
file.Write(LoadedText)
file.Close()
; Split on new line
oText := StrSplit(LoadedText, "`n")
oText.Delete(oText.MaxIndex())
return oText
} else {
Def := A_ScriptDir "\Skill\*.png"
return Def
}
}
FindSkill() {
SaveConf := AddConf()
if FileExist("SkillList.txt") {
Loop % SaveConf.MaxIndex() {
DirFile := SaveConf[A_Index]
ExecSkill(DirFile)
; MsgBox, % A_ScriptDir "\Skill\" SaveConf[A_Index]
}
} else {
DirFile := SaveConf
ExecSkill(DirFile)
}
}
ExecSkill(DirFile) {
; Xfb = 391, Yfb = 579
global Xfb , Yfb , tempskill , SkillList
; CoordMode, Mouse, Window
tes := ""
WinGet hwnd, ID, ahk_exe Game.exe
Xcps := Xfb ; 391
Ycps := Yfb ; 579
Wcps := (Xcps+390) ;391+390 = 781
Hcps := (Yfb+45) ; 579+45 = 624
slot_width := 39
global pToken := Gdip_Startup()
global pBitmapGameWin := Gdip_BitmapFromScreen("hwnd:" hwnd)
; Random, KeyD, 0, 300
Random, PressD, 50, 200
SetKeyDelay, , % PressD
; MsgBox, % A_ScriptDir "\Skill\" DirFile
loop % A_ScriptDir "\Skill\" DirFile , 1 , 1
{
MsgBox, % A_LoopFileFullPath
global pBitmapSkill := Gdip_CreateBitmapFromFile(A_LoopFileFullPath)
RET := Gdip_ImageSearch(pBitmapGameWin,pBitmapSkill,OutputList,Xcps,Ycps,Wcps,Hcps,,,,0)
if (RET > 0) {
; MsgBox, % "Sukses: " Xcps "," Ycps "," Wcps "," Hcps
;********************************************************
tes .= A_LoopFileName . "`n"
;********************************************************
temppos := StrSplit(OutputList, ",")
Xs := temppos[1]
Ys := temppos[2]
temppos := ""
column := Ceil((Xs-Xcps)/slot_width)
}
Gdip_DisposeImage(pBitmapSkill)
if !(column <= 0)
SendEvent, % column
column := ""
; Sleep 1000
}
Gdip_DisposeImage(pBitmapGameWin)
Gdip_Shutdown(pToken)
; MsgBox, Done, Please Re-Open Bot CL
; ExitApp
if !FileExist("SkillList.txt") {
file := FileOpen("SkillList.txt", "a `r`n")
file.Write(tes)
tes := ""
file.Close()
MsgBox, Done, Please Re-Open Bot CL
ExitApp
}
}
#If
$esc::
Gdip_DisposeImage(pBitmapSkill)
Gdip_DisposeImage(pBitmapGameWin)
Gdip_Shutdown(pToken)
ExitApp
Please pay attention to file looping(DirFile Variable). I thought that I could still speed up the image search process by saving the file name into a text file and then when the loop was done it would not search for all image files, but would only repeat from the file name that was saved in the text file.
In short, I want the code that I generated when I first run it will do a search for images of all the images and then save them in a text file, and if the text file containing the names of the image files already exists there is no need to do an image search of the entire file. But just search it from the names included in the text file.
I've checked my code many times and nothing seems wrong. But what I wanted didn't materialize, the file loop doesn't read the DirFile variable whose value is the filename of the text file I stored in the array.
Please help me, best regards and thank you.