Re: Need help with reading Minecraft chat
Posted: 24 Sep 2021, 08:11
Thats working fine but it still clicks even if the 2nd text (Du hast etwas aus dem Mülleimer geholt) is in log
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=18&t=94750
Code: Select all
#SingleInstance, force
log = C:\Users\garle\AppData\Roaming\.minecraft\logs\latest.log
lastLine(file) {
If FileExist(file) {
FileRead, ttext, %file%
line := StrSplit(Trim(ttext, "`r`n"), "`n")
Return line[line.Count()]
} Else MsgBox, 48, Error, File not found.`n`n%file%
}
loop {
If Instr(lastLine(log), "Du durchwühlst den Mülleimer")
If (ErrorLevel = 0) {
imagesearch, imgx1, imgy1, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\apple.png
if errorlevel = 1
sleep 1
else
Mouseclick , left, imgx1+10, imgy1+10, 1, 0
imagesearch, imgx2, imgy2, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\potato.png
if errorlevel = 1
sleep 1
else
Mouseclick , left, imgx2+10, imgy2+10, 1, 0
imagesearch, imgx3, imgy3, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\rottenflesh.png
if errorlevel = 1
sleep 1
else
Mouseclick , left, imgx3+10, imgy3+10, 1, 0
imagesearch, imgx4, imgy4, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\paper.png
if errorlevel = 1
sleep 1
else
Mouseclick , left, imgx4+10, imgy4+10, 1, 0
imagesearch, imgx5, imgy5, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\carrot.png
if errorlevel = 1
sleep 1
else {
Mouseclick , left, imgx5+10, imgy5+10, 1, 0
}}}
numpad3::ExitApp
Return