민서네집

[Autohotkey] 한영키 확인, 로그 파일에 기록 본문

Autohotkey

[Autohotkey] 한영키 확인, 로그 파일에 기록

브라이언7 2017. 12. 27. 21:36

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

; #Warn  ; Enable warnings to assist with detecting common errors.

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


;[출처] http://v1.autohotkey.co.kr/cgi/board.php?bo_table=qna&wr_id=39765

; 영어(0) 한글(1)

; Send {vk15sc138} 한/영키


;Msgbox % 한영확인() 

한영확인() 

IfEqual, hWnd,, WinGet, hWnd, ID, A 

DefaultIMEWnd  := DllCall( "imm32\ImmGetDefaultIMEWnd", "UInt", hWnd) 

DetectSaved = %A_DetectHiddenWindows% 

DetectHiddenWindows, On 

SendMessage, 0x283, 5, 0,, ahk_id %DefaultIMEWnd% 

IfNotEqual, A_DetectHiddenWindows, %DetectSaved%, DetectHiddenWindows, %DetectSaved% 

Return  ErrorLevel 


;로그 출력

; https://autohotkey.com/docs/Functions.htm


LogFileName = C:\logs\autohotkey.log


LogToFile(TextToLog)

{

    global LogFileName  ; This global variable was previously given a value somewhere outside this function.

FormatTime, now,,yyyy-MM-dd HH:mm:ss

    FileAppend, [%now%] %TextToLog%`n, %LogFileName%

}


CheckIME() 

{

ime = % 한영확인()

IfEqual, ime, 1, Send {vk15sc138}

}


CheckIME() 


Send, English



Comments