>

안녕하세요, 여러분

폴더 비교를위한 다음 코드는 다음과 같습니다. https://autohotkey.com/boards/viewtopic.php?f=5&t=44352&p=204630#p204630

#SingleInstance, Ignore
{
dir1 := ""
dir2 := ""
fileMask := ""
gosub, DoTheWork
Gui Add, ListBox, w530 r10 vfiles1, % "Dir1 = " dir1 "| |" list1
Gui Add, ListBox, w530 r10 vfiles2, % "Dir2 = " dir2 "| |" list2

Gui Add, Button, w50 gGuiOK default, OK
Gui Add, Button, x+10 w50 gGuiClose, Cancel
Gui,Add, Text, yp+5 x138,Dir1
Gui,Add, Edit, yp-3 x160 w90 vDir1,%dir1%
Gui,Add, Text, yp+2 x258,Dir2
Gui,Add, Edit, yp-3 x282 w90 vDir2,%dir2%
Gui,Add, Text, yp+2 x396,Mask
Gui,Add, Edit, yp-3 x423 w40 vFileMask,%fileMask%
Gui Add, Button, yp x483 w60 gGo, Go
;Gui Show, w1200
Gui Show, w550
Return
Go:
    Gui, Submit, NoHide 
    gosub, DoTheWork
    GuiControl,,files1,% "|Dir1 = " dir1 "| |" list1
    GuiControl,,files2,% "|Dir2 = " dir2 "| |" list2
return
GuiOK:
GuiClose:
GuiEscape:
ExitApp
DoTheWork:
filelist1 := filelist2 := ""    
list1 := list2 := ""    
Loop %dir1%\%fileMask%
{
If ( A_LoopFileName ~= "~\$")
        continue
    fileList1 .= A_LoopFileName . "`n"
    fnb1 := A_Index
}
StringTrimRight fileList1, fileList1, 1
Loop %dir2%\%fileMask%
{
    If ( A_LoopFileName ~= "~\$")
        continue
    fileList2 .= A_LoopFileName . "`n"
    fnb2 := A_Index
}
StringTrimRight fileList2, fileList2, 1
Sort fileList1
Sort fileList2
StringSplit files_1_, fileList1, `n
StringSplit files_2_, fileList2, `n
idxF1 := idxF2 := 1
Loop
{
    If (files_1_%idxF1% = files_2_%idxF2%)
    {
        ; We are in synch
        list1 .= files_1_%idxF1% . "|"
        idxF1++
        list2 .= files_2_%idxF2% . "|"
        idxF2++
    }
    Else
    {
        ; Either file at idxF1 or at idxF3 is missing, we must find which one
        If (files_1_%idxF1% > files_2_%idxF2%)
        {
            ; Missing in first list
            list1 .= " |"   ; Empty
            list2 .= files_2_%idxF2% . "|"
            idxF2++
        }
        Else
        {
            ; Missing in second list
            list1 .= files_1_%idxF1% . "|"
            idxF1++
            list2 .= " |"   ; Empty
        }
    }
    If (idxF1 > fnb1)
    {
        Loop % fnb2 - idxF2 + 1
        {
            list1 .= " |"   ; Empty
            list2 .= files_2_%idxF2% . "|"
            idxF2++
        }
        Break
    }
    If (idxF2 > fnb2)
    {
        Loop % fnb1 - idxF1 + 1
        {
            list1 .= files_1_%idxF1% . "|"
            idxF1++
            list2 .= " |"   ; Empty
        }
        Break
    }
}
StringTrimRight list1, list1, 1
StringTrimRight list2, list2, 1
Return
}

다음 부분을 추가했는데 폴더 경로와 파일 형식을 설정하는 3 개의 단축키가 있습니다 :

SetTitleMatchMode, 1
#IfWinActive, Comparison
$1::
ControlSetText, Edit1, E:\ask\work
ControlSetText, Edit2, E:\ask\backup
ControlSetText, Edit3, *.docx
ControlClick, Go, Comparison  
return
;;---------------------------------------------------  2
$2::
ControlSetText, Edit1, E:\ask\sales
ControlSetText, Edit2, E:\ask\work
ControlSetText, Edit3, *.pdf
ControlClick, Go, Comparison  
return
;;---------------------------------------------------  3
$3::
ControlSetText, Edit1, E:\ask\sales
ControlSetText, Edit2, E:\ask\backup
ControlSetText, Edit3, *.txt
ControlClick, Go, Comparison  
return

코드는 처음까지 제대로 작동하지 않습니다. 첨부 된 그림 (1)을 참조하십시오. 모든 것이 사실입니다 그러나 다음 시간은 정확하지 않습니다 다시로드하지 않거나 프로그램을 닫았다가 다시 열지 않는 한 첨부 된 그림의 오류를 참조하십시오. 버그

누구나이 오류를 해결할 수 있습니까?


  • 답변 # 1

    핫키가 이제 gui 변수를 채우고 gui로 보내면 자동으로 실행되도록 약간 변경했습니다.

    #SingleInstance, Ignore
    {
    dir1 := ""
    dir2 := ""
    fileMask := ""
    ;gosub, DoTheWork ;unnecessary here
    Gui:
    Gui Add, ListBox, w530 r10 vfiles1, % "Dir1 = " dir1 "| |" list1
    Gui Add, ListBox, w530 r10 vfiles2, % "Dir2 = " dir2 "| |" list2
    Gui Add, Button, w50 gGuiOK default, OK
    Gui Add, Button, x+10 w50 gGuiClose, Cancel
    Gui,Add, Text, yp+5 x138,Dir1
    Gui,Add, Edit, yp-3 x160 w90 vDir1,%dir1%
    Gui,Add, Text, yp+2 x258,Dir2
    Gui,Add, Edit, yp-3 x282 w90 vDir2,%dir2%
    Gui,Add, Text, yp+2 x396,Mask
    Gui,Add, Edit, yp-3 x423 w40 vFileMask,%fileMask%
    Gui Add, Button, yp x483 w60 gGo, Go
    ;Gui Show, w1200
    Gui Show, w550
    ControlClick, Go, ahk_exe AutoHotkey.exe ;;changed location of ControlClick from hotkeys to here
    Return
    Go:
        Gui, Submit, NoHide 
        gosub, DoTheWork
        GuiControl,,files1,% "|Dir1 = " dir1 "| |" list1
        GuiControl,,files2,% "|Dir2 = " dir2 "| |" list2
    return
    GuiOK:
    GuiClose:
    GuiEscape:
    ExitApp
    DoTheWork:
    filelist1 := filelist2 := ""    
    list1 := list2 := ""    
    Loop %dir1%\%fileMask%
    {
    If ( A_LoopFileName ~= "~\$")
            continue
        fileList1 .= A_LoopFileName . "`n"
        fnb1 := A_Index
    }
    StringTrimRight fileList1, fileList1, 1
    Loop %dir2%\%fileMask%
    {
        If ( A_LoopFileName ~= "~\$")
            continue
        fileList2 .= A_LoopFileName . "`n"
        fnb2 := A_Index
    }
    StringTrimRight fileList2, fileList2, 1
    Sort fileList1
    Sort fileList2
    StringSplit files_1_, fileList1, `n
    StringSplit files_2_, fileList2, `n
    idxF1 := idxF2 := 1
    Loop
    {
        If (files_1_%idxF1% = files_2_%idxF2%)
        {
            ; We are in synch
            list1 .= files_1_%idxF1% . "|"
            idxF1++
            list2 .= files_2_%idxF2% . "|"
            idxF2++
        }
        Else
        {
            ; Either file at idxF1 or at idxF3 is missing, we must find which one
            If (files_1_%idxF1% > files_2_%idxF2%)
            {
                ; Missing in first list
                list1 .= " |"   ; Empty
                list2 .= files_2_%idxF2% . "|"
                idxF2++
            }
            Else
            {
                ; Missing in second list
                list1 .= files_1_%idxF1% . "|"
                idxF1++
                list2 .= " |"   ; Empty
            }
        }
        If (idxF1 > fnb1)
        {
            Loop % fnb2 - idxF2 + 1
            {
                list1 .= " |"   ; Empty
                list2 .= files_2_%idxF2% . "|"
                idxF2++
            }
            Break
        }
        If (idxF2 > fnb2)
        {
            Loop % fnb1 - idxF1 + 1
            {
                list1 .= files_1_%idxF1% . "|"
                idxF1++
                list2 .= " |"   ; Empty
            }
            Break
        }
    }
    StringTrimRight list1, list1, 1
    StringTrimRight list2, list2, 1
    Return
    SetTitleMatchMode, 1
    #IfWinActive, Comparison
    $1::
    Gui,Destroy
    Dir1 := "E:\ask\work"
    Dir2 := "E:\ask\backup"
    FileMask := "*.docx"
    GoSub, Gui
    return
    ;;---------------------------------------------------  2
    $2::
    Gui,Destroy
    Dir1 := "E:\ask\work"
    Dir2 := "E:\ask\backup"
    FileMask := ".pdf"
    GoSub, Gui
    return
    ;;---------------------------------------------------  2
    $3::
    Gui,Destroy
    Dir1 := "E:\ask\work"
    Dir2 := "E:\ask\backup"
    FileMask := "*.txt"
    GoSub, Gui
    return
    #IfWinActive
    }
    
    

  • 답변 # 2

    DoTheWork:
    filelist1 := filelist2 := ""
    list1 := list2 := ""
    fnb1 := fnb2 := 0 ; <<<<< added: initialize the counters
    Loop %dir1%\%fileMask%
    {
    If ( A_LoopFileName ~= "~\$")
            continue
        fileList1 .= A_LoopFileName . "`n"
        fnb1++ ; <<<<< changed: don't use A_Index because some files may be skipped
    }
    StringTrimRight fileList1, fileList1, 1
    Loop %dir2%\%fileMask%
    {
        If ( A_LoopFileName ~= "~\$")
            continue
        fileList2 .= A_LoopFileName . "`n"
        fnb2++ ; <<<<< changed: don't use A_Index because some files may be skipped
    }
    StringTrimRight fileList2, fileList2, 1
    If (fnb1 = 0) && (fnb2 = 0) ; <<<<< added: early return
        Return
    Sort fileList1
    Sort fileList2
    StringSplit files_1_, fileList1, `n
    StringSplit files_2_, fileList2, `n
    idxF1 := idxF2 := 1
    Loop
    {
        If (idxF1 > fnb1) ; <<<<< moved to the top of the loop
        {
            Loop % fnb2 - idxF2 + 1
            {
                list1 .= " |"   ; Empty
                list2 .= files_2_%idxF2% . "|"
                idxF2++
            }
            Break
        }
        If (idxF2 > fnb2) ; <<<<< moved to the top of the loop
        {
            Loop % fnb1 - idxF1 + 1
            {
                list1 .= files_1_%idxF1% . "|"
                idxF1++
                list2 .= " |"   ; Empty
            }
            Break
        }
        If (files_1_%idxF1% = files_2_%idxF2%)
        {
            ; We are in synch
            list1 .= files_1_%idxF1% . "|"
            idxF1++
            list2 .= files_2_%idxF2% . "|"
            idxF2++
        }
        Else
        {
            ; Either file at idxF1 or at idxF3 is missing, we must find which one
            If (files_1_%idxF1% > files_2_%idxF2%)
            {
                ; Missing in first list
                list1 .= " |"   ; Empty
                list2 .= files_2_%idxF2% . "|"
                idxF2++
            }
            Else
            {
                ; Missing in second list
                list1 .= files_1_%idxF1% . "|"
                idxF1++
                list2 .= " |"   ; Empty
            }
        }
    }
    StringTrimRight list1, list1, 1
    StringTrimRight list2, list2, 1
    Return
    #IfWinActive, ask final
    $1::
    ControlSetText, Edit1, E:\ask\work
    ControlSetText, Edit2, E:\ask\backup
    ControlSetText, Edit3, *.docx
    ControlClick, Go, Comp
    return
    ;;---------------------------------------------------  2
    $2::
    ControlSetText, Edit1, E:\ask\sales
    ControlSetText, Edit2, E:\ask\work
    ControlSetText, Edit3, *.xlsx
    ControlClick, Go, Comp 
    return
    ;;---------------------------------------------------  3
    $3::
    ControlSetText, Edit1, E:\ask\sales
    ControlSetText, Edit2, E:\ask\backup
    ControlSetText, Edit3, *.txt
    ControlClick, Go, Comp
    return
    
    

  • 이전 javascript - materialize material_select는 함수 오류가 아닙니다
  • 다음 C에서 트리플 데 cbc 암호화