È­¸é À§ Å°º¸µå (XP/2k/NT ¿ä±¸) -- by Jon

ÀÌ ½ºÅ©¸³Æ®´Â °¡Â¥ Å°º¸µå¸¦ È­¸é ¾Æ·¡¿¡ »ý¼ºÇÏ°í ´©¸£´Â Å°µéÀ» ½Ç½Ã°£À¸·Î º¸¿©ÁÝ´Ï´Ù. (Å°º¸µå¸¦ º¸Áö ¾Ê°í) ¼Õ°¨°¢À» ÀÍÈ÷±â À§ÇØ ¸¸µé¾ú½À´Ï´Ù. È­¸é À§ Å°º¸µåÀÇ Å©±â´Â ½ºÅ©¸³Æ® »ó´Ü¿¡¼­ Àç´ÜÇÒ ¼ö ÀÖ½À´Ï´Ù. ¶ÇÇÑ, Æ®·¹ÀÌ ¾ÆÀÌÄÜÀ» ´õºí Ŭ¸¯Çϸé Å°º¸µå¸¦ º¸¿©Áְųª °¨Ãâ ¼ö ÀÖ½À´Ï´Ù.

ÀÌ ½ºÅ©¸³Æ® ³»·Á ¹Þ±â  |  ´Ù¸¥ »ùÇà ½ºÅ©¸³Æ®  |  È¨À¸·Î

;---- ȯ°æ ±¸¼º ºÎºÐ: È­¸é À§ Å°º¸µå Å©±â¿Í
; ±âŸ ¿É¼ÇÀ» ¿©±â¿¡¼­ Àç´ÜÇÕ´Ï´Ù.

; ´ÙÀ½ ±Û²Ã Å©±â¸¦ ¹Ù²Ù¸é Àü¿¡ È­¸é À§ Å°º¸µå°¡
; ´õ Ä¿Áö°Å³ª ´õ ÀÛ¾ÆÀÔ´Ï´Ù:
k_FontSize = 10
k_FontName = Verdana  ; ÀÌ ÁÙÀ» ºñ¿ì¸é ½Ã½ºÅÛÀÇ ±âº» ±Û²ÃÀ» »ç¿ëÇÕ´Ï´Ù.
k_FontStyle = Bold    ; ´Ù¸¥ ¿¹Á¦: Italic Underline

; Æ®·¹ÀÌ ¸Þ´º Ç׸ñ À̸§:
k_MenuItemHide = Hide on-screen &keyboard
k_MenuItemShow = Show on-screen &keyboard

; ±âº» ¸ðµðÅÍ ¸»°í ´Ù¸¥ ¸ð´ÏÅÍ¿¡ Å°º¸µå¸¦ º¸¿©ÁÖ·Á¸é,
; ´ÙÀ½ º¯¼ö¿¡ 2¿Í °°ÀÌ ¼ýÀÚ¸¦ ÁöÁ¤ÇϽʽÿÀ. ºñ¿öµÎ¸é,
; ±âº» ¸ð´ÏÅ͸¦ »ç¿ëÇÕ´Ï´Ù:
k_Monitor = 

;---- ȯ°æ ±¸¼º ºÎºÐ ³¡.  ÀÌ ½ÃÁ¡ ºÎÅÍ´Â º¯°æÇÏÁö ¸¶½Ê½Ã¿À.
; ´Ü, ½ºÅ©¸³Æ®ÀÌ ±âº» ¼º°ÝÀ» ¹Ù²Ù°í ½ÍÀº °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù.


;---- Æ®·¹ÀÌ ¾ÆÀÌÄÜ ¸Þ´º¸¦ º¯°æÇÕ´Ï´Ù:
Menu, Tray, Add, %k_MenuItemHide%, k_ShowHide
Menu, Tray, Add, &Exit, k_MenuExit
Menu, Tray, Default, %k_MenuItemHide%
Menu, Tray, NoStandard

;---- ¼±ÅÃµÈ ±Û²Ã Å©±â¿¡ ±â¹ÝÇÏ¿© °´Ã¼ Å©±â¸¦ °è»êÇÕ´Ï´Ù.:
k_KeyWidth = %k_FontSize%
k_KeyWidth *= 3
k_KeyHeight = %k_FontSize%
k_KeyHeight *= 3
k_KeyMargin = %k_FontSize%
k_KeyMargin /= 6
k_SpacebarWidth = %k_FontSize%
k_SpacebarWidth *= 25
k_KeyWidthHalf = %k_KeyWidth%
k_KeyWidthHalf /= 2

k_KeySize = w%k_KeyWidth% h%k_KeyHeight%
k_Position = x+%k_KeyMargin% %k_KeySize%

;---- È­¸é À§ Å°º¸µå¸¦ À§ÇÏ¿© GUI âÀ» »ý¼ºÇÕ´Ï´Ù:
Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
Gui, -Caption +E0x200 +ToolWindow
TransColor = F1ECED
Gui, Color, %TransColor%  ; ÀÌ »öÀº ³ªÁß¿¡ ¾Æ·¡¿¡¼­ Åõ¸í»öÀÌ µË´Ï´Ù.

;---- °¢ Å°¿¡ ¹öÆ°À» Ãß°¡ÇÕ´Ï´Ù. ù ¹öÆ°À» Àý´ë ÁÂÇ¥¿¡ ¹èÄ¡ÇÕ´Ï´Ù.
; ±×·¯¸é ´Ù¸¥ ¸ðµç ¹öÆ°ÀÌ ±×¿¡ »ó´ëÀûÀ¸·Î ¹èÄ¡µË´Ï´Ù:
Gui, Add, Button, section %k_KeySize% xm+%k_KeyWidth%, 1
Gui, Add, Button, %k_Position%, 2
Gui, Add, Button, %k_Position%, 3
Gui, Add, Button, %k_Position%, 4
Gui, Add, Button, %k_Position%, 5
Gui, Add, Button, %k_Position%, 6
Gui, Add, Button, %k_Position%, 7
Gui, Add, Button, %k_Position%, 8
Gui, Add, Button, %k_Position%, 9
Gui, Add, Button, %k_Position%, 0
Gui, Add, Button, %k_Position%, -
Gui, Add, Button, %k_Position%, =
Gui, Add, Button, %k_Position%, Bk

Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, Tab  ; ÀÚµ¿-³Êºñ.
Gui, Add, Button, %k_Position%, Q
Gui, Add, Button, %k_Position%, W
Gui, Add, Button, %k_Position%, E
Gui, Add, Button, %k_Position%, R
Gui, Add, Button, %k_Position%, T
Gui, Add, Button, %k_Position%, Y
Gui, Add, Button, %k_Position%, U
Gui, Add, Button, %k_Position%, I
Gui, Add, Button, %k_Position%, O
Gui, Add, Button, %k_Position%, P
Gui, Add, Button, %k_Position%, [
Gui, Add, Button, %k_Position%, ]
Gui, Add, Button, %k_Position%, \

Gui, Add, Button, xs+%k_KeyWidthHalf% y+%k_KeyMargin% %k_KeySize%, A
Gui, Add, Button, %k_Position%, S
Gui, Add, Button, %k_Position%, D
Gui, Add, Button, %k_Position%, F
Gui, Add, Button, %k_Position%, G
Gui, Add, Button, %k_Position%, H
Gui, Add, Button, %k_Position%, J
Gui, Add, Button, %k_Position%, K
Gui, Add, Button, %k_Position%, L
Gui, Add, Button, %k_Position%, `;
Gui, Add, Button, %k_Position%, '
Gui, Add, Button, x+%k_KeyMargin% h%k_KeyHeight%, Enter  ; ÀÚµ¿-³Êºñ.

; ¾Æ·¡ÀÇ Ã¹ ¹ø° ¹öÆ°Àº ³¡¿¡ %A_Space%¸¦ Ãß°¡ÇØ ¾à°£ ´õ ³ÐÈü´Ï´Ù.
; ±×·¡¼­ ±× ´ÙÀ½ Å°¿ÍÀÇ ·¹À̾ƿôÀÌ ´õ Á¤È®ÇÏ°Ô Å°º¸µå¸¦ ¹Ý¿µÇÕ´Ï´Ù.:
Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, Shift%A_Space%%A_Space%
Gui, Add, Button, %k_Position%, Z
Gui, Add, Button, %k_Position%, X
Gui, Add, Button, %k_Position%, C
Gui, Add, Button, %k_Position%, V
Gui, Add, Button, %k_Position%, B
Gui, Add, Button, %k_Position%, N
Gui, Add, Button, %k_Position%, M
Gui, Add, Button, %k_Position%, `,
Gui, Add, Button, %k_Position%, .
Gui, Add, Button, %k_Position%, /

Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, Ctrl  ; Auto-width.
Gui, Add, Button, h%k_KeyHeight% x+%k_KeyMargin%, Win      ; Auto-width.
Gui, Add, Button, h%k_KeyHeight% x+%k_KeyMargin%, Alt      ; Auto-width.
Gui, Add, Button, h%k_KeyHeight% x+%k_KeyMargin% w%k_SpacebarWidth%, Space


;---- âÀ» º¸¿©ÁÝ´Ï´Ù:
Gui, Show
k_IsVisible = y

WinGet, k_ID, ID, A   ; Get its window ID.
WinGetPos,,, k_WindowWidth, k_WindowHeight, A

;---- (ŽºÅ©¹ÙÀÇ À§Ä¡¸¦ °í·ÁÇÏ¿©)
; Å°º¸µå¸¦ È­¸é ¾Æ·¡¿¡ ¹èÄ¡ÇÕ´Ï´Ù:
SysGet, k_WorkArea, MonitorWorkArea, %k_Monitor%

; âÀÇ X-À§Ä¡¸¦ °è»êÇÕ´Ï´Ù:
k_WindowX = %k_WorkAreaRight%
k_WindowX -= %k_WorkAreaLeft%  ; ÀÌÁ¦ k_WindowX¿¡ ÀÌ ¸ð´ÏÅÍÀÇ ³Êºñ°¡ ´ã±é´Ï´Ù.
k_WindowX -= %k_WindowWidth%
k_WindowX /= 2  ; ¼öÆòÀ¸·Î °¡¿îµ¥ À§Ä¡¸¦ °è»êÇÕ´Ï´Ù.
; ´ÙÀ½Àº âÀÌ ±âº» ¸ð´ÏÅÍ¿¡ ÀÖÁö ¾Ê°Å³ª
; ŽºÅ©¹Ù°¡ È­¸é ¿ÞÂÊ º¯¿¡ Á¤¹ÚµÇ¾î ÀÖ´Â °æ¿ì¸¦ ó¸®ÇÕ´Ï´Ù:
k_WindowX += %k_WorkAreaLeft%

; âÀÇ Y-À§Ä¡¸¦ °è»êÇÕ´Ï´Ù:
k_WindowY = %k_WorkAreaBottom%
k_WindowY -= %k_WindowHeight%

WinMove, A,, %k_WindowX%, %k_WindowY%
WinSet, AlwaysOnTop, On, ahk_id %k_ID%
WinSet, TransColor, %TransColor% 220, ahk_id %k_ID%


;---- ¸ðµç Å°¸¦ ÇÖÅ°·Î ¼³Á¤ÇÕ´Ï´Ù. ÂüÁ¶ www.asciitable.com
k_n = 1
k_ASCII = 45

Loop
{
    Transform, k_char, Chr, %k_ASCII%
    StringUpper, k_char, k_char
    if k_char not in <,>,^,~,,`,
        Hotkey, ~*%k_char%, k_KeyPress
        ; À§¿¡¼­, º°Ç¥ Á¢µÎ ½Éº¼ ´öºÐ¿¡ »ç¿ëÀÚ°¡ Control°ú Shift °°Àº ¼ö½Ä Å°¸¦ ´©¸£°í ÀÖµç ¾øµç
        ; Å°¸¦ ŽÁöÇÒ ¼ö ÀÖ½À´Ï´Ù.
    if k_ASCII = 93
        break
    k_ASCII++
}

return ; ÀÚµ¿ ½ÇÇà ¼½¼ÇÀÇ ³¡.


;---- »ç¿ëÀÚ°¡ Å°¸¦ ´©¸£¸é, È­¸é À§¿¡¼­ »óÀÀÇÏ´Â ¹öÆ°À» Ŭ¸¯ÇÕ´Ï´Ù:

~*Backspace::
ControlClick, Bk, ahk_id %k_ID%, , LEFT, 1, D
KeyWait, Backspace
ControlClick, Bk, ahk_id %k_ID%, , LEFT, 1, U
return


;  "Shift" ´ë½Å¿¡ LShift¿Í RShift¸¦ »ç¿ëÇÕ´Ï´Ù. ¿Ö³ÄÇϸé ÇÖÅ°·Î »ç¿ëµÉ ¶§,
; "Shift"´Â ±âº»ÀûÀ¸·Î Å°¸¦ ¶¿ ¶§ Ã˹ߵDZ⠶§¹®ÀÔ´Ï´Ù (¿¹Àü AHK ¹öÀü¿¡¼­):
~*LShift::
~*RShift::
~*LCtrl::  ; Control ´ë½Å¿¡ CtrlÀ» »ç¿ëÇØ¾ß ¹öÆ° À̸§¿¡ ºÎÇÕÇÒ ¼ö ÀÖ½À´Ï´Ù.
~*RCtrl::
~*LAlt::
~*RAlt::
~*LWin::
~*RWin::
StringTrimLeft, k_ThisHotkey, A_ThisHotkey, 3
ControlClick, %k_ThisHotkey%, ahk_id %k_ID%, , LEFT, 1, D
KeyWait, %k_ThisHotkey%
ControlClick, %k_ThisHotkey%, ahk_id %k_ID%, , LEFT, 1, U
return


~*,::
~*'::
~*Space::
~*Enter::
~*Tab::
k_KeyPress:
StringReplace, k_ThisHotkey, A_ThisHotkey, ~
StringReplace, k_ThisHotkey, k_ThisHotkey, *
SetTitleMatchMode, 3  ; T Å°¿Í B Å°¸¦ Tab°ú Backspace·Î È¥µ¿ÇÏÁö ¾Êµµ·Ï ¹æÁöÇÕ´Ï´Ù.
ControlClick, %k_ThisHotkey%, ahk_id %k_ID%, , LEFT, 1, D
KeyWait, %k_ThisHotkey%
ControlClick, %k_ThisHotkey%, ahk_id %k_ID%, , LEFT, 1, U
Return


k_ShowHide:
if k_IsVisible = y
{
    Gui, Cancel
    Menu, Tray, Rename, %k_MenuItemHide%, %k_MenuItemShow%
    k_IsVisible = n
}
else
{
    Gui, Show
    Menu, Tray, Rename, %k_MenuItemShow%, %k_MenuItemHide%
    k_IsVisible = y
}
return


GuiClose:
k_MenuExit:
ExitApp