((AHK)禁止复制相似的行2次

问题描述 投票:0回答:1

因此,我需要将游戏日志复制到我自己的txt(日志)中,但是它将相似的行复制了2次以上,并且只是“杀死”了我的记忆。这是代码:

Numpad0::
{
Loop
{
FileEncoding, UTF-8
Loop, Read, C:\Users\макс\AppData\Roaming\.vimeworld\minigames\logs\latest.log, `n, `r
    {
     last_line := A_LoopReadLine
    }
FileAppend, %last_line%`n, D:\person\txt\Prison\Prison Boss Reminder\vwlc.txt**
IfInString, last_line, [CHAT] Королевский зомби был повержен! Нападавшие получили ценные сокровища!
{
FileAppend, [SoulSky] Boss!, C:\Users\макс\AppData\Roaming\.vimeworld\minigames\logs\latest.log
}
}
}
Return


Numpad1::
Reload

所以我需要检查上次复制的字符串是否相似,并且是否相似>不要再次复制。

autohotkey copying
1个回答
0
投票

尝试这样的事情:

Numpad0::
    SetTimer, read_last_line, 500 ; every 0.5 seconds
Return 

read_last_line:
    last_line := "" ; empty this variable
    Loop, Read, C:\Users\макс\AppData\Roaming\.vimeworld\minigames\logs\latest.log, `n, `r
         last_line := A_LoopReadLine
    If (last_line != Current_last_line)
    {
        Current_last_line := ""
        FileAppend, %last_line%`n, D:\person\txt\Prison\Prison Boss Reminder\vwlc.txt**
        IfInString, last_line, [CHAT] Королевский зомби был повержен! Нападавшие получили ценные сокровища!
            FileAppend, [SoulSky] Boss!, C:\Users\макс\AppData\Roaming\.vimeworld\minigames\logs\latest.log
        Current_last_line := last_line  ; store the value of the variable "last_line" in the variable "Current_last_line". This way you can compare those values next time the timer is executed.
    }
Return

Numpad1::
    SetTimer, read_last_line, off
Return
© www.soinside.com 2019 - 2024. All rights reserved.