.ahk 파일을 메모장으로 열어서 '유니코드' 또는 'UTF-8'로 저장해주지않으면 소스 작성시 한글이 꺠집니다.
그래서 외국포럼에서 소스코드를 받아 수정할때 저 번거로운 작업을 거쳐야했는데요.
스크립트 수정툴인 AHK Studio 으로 스크립트 수정시 한글이 깨져서 관련파일을 전부 유니코드로 바꿔야하는데..
파일수가 120 개정도 되더라구요 ;; 답이 없어서 한번에 인코딩 변환하는 툴을 제작해보았습니다.
ahk.org 에 발전된 소스코드 올렸습니다.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force
#NoTrayIcon
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
nb = 1
MsgBox, 4160, 중요한 정보, 변환할 스크립트(.ahk) 파일이 있는 경로에서 실행하셔야합니다!
Gui, add, edit, xm+420 ym w400 h260 vStrIn, 변환될 소스코드`n드래그드롭가능해요
;Gui, add, edit, xm y+30 w500 h200 vStrOut, Changed
Gui, add, ListView, xm ym w400 h260 vmyListView gAHKlist AltSubmit, 파일명|경로
Gui, add, button, xm+420 ym+265 w100 h30, 개별변환
Gui, add, button, xm ym+265 w100 h30 gAHKget, 파일 불러오기
Gui, add, button, xm+120 ym+265 w100 h30, 전부변환
LV_ModifyCol(1, 150)
LV_ModifyCol(2, 230)
Gui, show, Autosize, 스크립트 인코딩 변환기 by 예지력(knowledgeisfree.tistory.com)
return
AHKget:
LV_DELETE()
Loop, %A_ScriptDir%\*.ahk
{
Howmuch := A_Index
File%A_Index% := A_LoopFileName
LV_Add("", A_LoopFileName, A_LoopFileDir)
}
Gui, +OwnDialogs
MsgBox, 4160, , % Howmuch "개의 스크립트를 불러왔습니다!"
return
AHKlist:
Gui,Submit,NoHide
if (lv_getcount() > 0)
{
if A_GuiEvent = DoubleClick
{
StrIn := ""
GuiControl,, StrIn,
LV_GetText(ThisName, A_EventInfo, 1)
FileRead, Opt2, %ThisName%
GuiControl,, StrIn, %Opt2%
}
}
return
Button전부변환:
Gui,Submit,NoHide
while nb <= LV_GetCount()
{
StrIn := ""
GuiControl,, StrIn,
LV_GetText(TrueName, A_Index)
FileRead, Opt2, %TrueName%
GuiControl,, StrIn, %Opt2%
FileDelete, %TrueName%
FileAppend, %Opt2%, %TrueName%, UTF-16
MsgBox % TrueName "완료"
nb ++
}
nb := 1
return
Button개별변환:
Gui, Submit, NoHide
FileDelete, %FileName%
StringReplace, op1, FileName, %A_ScriptDir%\,, All
FileAppend, %StrIn%, %op1%, UTF-16
return
GuiDropFiles:
FileEncoding, UTF-8
StrIn := ""
GuiControl,, Strin,
if A_GuiControl = StrIn
{
FileName := A_GuiEvent
FileRead, Draged, %A_GuiEvent%
GuiControl,, StrIn, %Draged%
}
return
GuiClose:
ExitApp