아래 포스팅에서 밝힌 바와 같이 Autohotkey에서는 ComObjCreate() 함수를 사용하여 COM object 를 사용 할 수 있습니다.
2012/08/16 - [programming language/Autohotkey] - Autohotkey_L을 이용한 MS Word 자동화
2012/06/24 - [programming language/Autohotkey] - Autohotkey_L 로 구글 검색하기
2012/05/21 - [programming language/Autohotkey] - Autohotkey_L Text to Speech
오늘은 ComObjCreate()를 사용하여 Autohotkey에서 VBScript 과 JScript 언어를 실행하는 방법에 대해 알아보려 합니다.
저는 현재 윈도우 7 64 비트 환경에 Autohotkey UNICODE 64 비트를 설치했었는데~ 64 비트에서는 ComObjCreate("ScriptControl") 가 정상적으로 실행되지 않더군요.
그래서 UNICODE 32 비트를 설치했습니다.
샘플로 실행해본 코드는 인터넷에서 찾아본 코드들로 다음과 같습니다.
첫 번재로 VBScript 입니다.
sc := ComObjCreate("ScriptControl")
;// define the Language
sc.Language := "VBScript"
;// define the VBScript
script =
(
Dim string
Arr = Array("Auto", "Hot", "key!")
For Each i In Arr
string = string & i
Next
MsgBox "Joined Array Elements:" & vbCR & string, 64, "VBScript MsgBox"
)
;// execute the VBScript
sc.ExecuteStatement(script)
;// extract values from the VBScript
MsgBox, 64, AutoHotkey MsgBox, % "Joined Array Elements:`n" sc.Eval("Arr(0) & Arr(1) & Arr(2)")
다음과 같은 실행 결과가 나오더군요.
두 번째로 JScript예제 입니다. 아래 예제는 Autohotkey 에서 JScript를 사용하여 URI Encoding 하는 예제 인데~
UriEncode(Uri)
{
oSC := ComObjCreate("ScriptControl")
oSC.Language := "JScript"
Script := "var Encoded = encodeURIComponent(""" . Uri . """)"
oSC.ExecuteStatement(Script)
Return, oSC.Eval("Encoded")
}
UriDecode(Uri)
{
oSC := ComObjCreate("ScriptControl")
oSC.Language := "JScript"
Script := "var Decoded = decodeURIComponent(""" . Uri . """)"
oSC.ExecuteStatement(Script)
Return, oSC.Eval("Decoded")
}
keyword := UriEncode("한글")
MsgBox % keyword
한글이라는 글자가 다음과 같이 encoding 돼서 나오더군요.
'programming language > Autohotkey' 카테고리의 다른 글
Autohotkey에서 ImageMagick 사용하기 (0) | 2014.05.05 |
---|---|
Autohotkey Com Object HTMLFile 을 사용한 링크 가져오기 (2) | 2014.04.27 |
Autohotkey 를 사용하여 창 정보 얻기 AHK_Window_Info_v1.7.ahk (0) | 2014.04.12 |
Autohotkey 로 달러 조회 하기 (0) | 2014.04.07 |
Notepad++ 에서 Autohotkey 코딩 하기 (2) | 2014.02.18 |
Autohotkey Group 사용하기 GroupAdd, GroupClose (0) | 2014.02.11 |
Autohotkey 로 한/영 키 매핑 바꾸기 (0) | 2014.02.09 |
Autohotkey를 사용한 영어 자동 타이핑 TypingAid (0) | 2013.12.24 |
댓글