본문 바로가기

소프트웨어/스크립트천국

오토핫키 왕초보 (2)

반응형

AutoHotkey Baby step (2)
직관적인 매크로 프로그램 입문

첫편에 말한 것 처럼 여기는 오토핫키 왕초보를 위한 이야기이기 때문에 무난히 사용하는분들은 보지 말기를 바랍니다.[웹게임은 매크로가 정복한다.]

오토핫키는 상업적인 프로그램이 아닙니다.
그래서 보기좋게 화장을 하지 않는 심플한 인터페이스로 필요한것만 나열합니다.
사용해 볼수록 맘에 드는 구성이라고 생각합니다.
그래서 첨엔 당황스럽기도 하지요.

첨에 소프트웨어를 인스톨하면 아래와같은 4개의 실행파일이 있는데 먼저 AutoHotkey.exe를 실행하면

사용자 삽입 이미지


아래 BOX안의 모습으로 뜰것입니다.
이렇게 뜨면 정상적으로 인스톨 된것이며 매크로 명령만 안다면 고급 매크로를 바로 짤수 있는 환경이 된것이며 파일은 AutoHotkey.ahk를 불러온것입니다.

실제로 아무것도 안불러오고 블랭크(빈 백지 화면이 나오면 차라리 덜 황당할지도 모름)파일이 더 낳을지도 모릅니다.

불러온 파일은 지우든지 놔두던지 하고 모든것을 지우고 Test.ahk 정도의 파일을 만들어 시험하는게 좋다고 생각합니다.

1.AutoHotke.exe
오토핫키

2.AutoScriptWriter (recorder)
3.AutoIt3 Window Spy
4.Convert .ahk to .exe
이 네가지의 실행파일 중에서 1번은 실행파일이며 매크로 스크립트를 만들고 실행하고 편집하는 핵심 파일이며 이것으로 모든 작업을 하게 됩니다.
2번은 매크로를 만들것을 미리 사용자가 시행해보면 시행한대로 매크로형태의 스크립트로 나영해 주며 그대로 복사해서 돌리도 돌아가는 말그대로 실행상태 녹화기와 같은것입니다.
3번은 내가 실행한 작업이 윈도상에서 어떤명령어를 택해서 실행되게 되는가를 명령어상으로 조합할수 있도록 나열해 줍니다.
4번은 완벽할 만큼 잘 짜여진 매크로가 탄생하면 오토핫키가 깔리지 않은 어떤 PC상에서도 바로 사용할수 있도록 실행파일로 만들어 줍니다.
   

; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments.  They are not executed.

; This script has a special filename and path because it is automatically
; launched when you run the program directly.  Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it.  You can have as many .ahk
; files as you want, located in any folder.  You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.

; SAMPLE HOTKEYS: Below are two sample hotkeys.  The first is Win+Z and it
; launches a web site in the default browser.  The second is Control+Alt+N
; and it launches a new Notepad window (or activates an existing one).  To
; try out these hotkeys, run AutoHotkey again, which will load this file.

#z::Run www.autohotkey.com

^!n::
IfWinExist Untitled - Notepad
    WinActivate
else
    Run Notepad
return


; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded.  So feel free to customize it to suit your needs.

; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks.  It also explains more about hotkeys.

박스안의 텍스트로 된 문서를 매크로 문서라 하며 이 매크로 문서는 확장자가 TXT 상태로 보관하여 언제나 수정 보완하며 보관용으로 하는게 좋을것이며,
매크로 동작을 바로 시킬때는 확장자 ahk로 저장하면 됩니다.

위의 박스 안의 많은 텍스트는 " ; " 를 전치한 문장은 주석문입니다.
매크로를 짜면서 자기가 짠것이지만 편리를 위해서 문장마다 꼼꼼하게 주석문을 붙이는 습관을 들이는게 좋습니다.
" ; "표시가 없는 문장은 매크로 문장입니다.
수많은 다양한 매크로 명령어를 준비하고 있으며 고급 유저는 함수를 만들수도 있지만 기본적으로 제공하는 매크로 명령어 만 으로도 부족함이 없는 매크로를 만들수 있을것입니다.

별거아닌 이야기이지만 모르는분이 있다면 도움되었으면 좋겠습니다.
다음에는 아래 명령어 리스트를 근거로 해서 실제 구성을 함께 해 볼것입니다.

영문해석은 천천이 사용례를 쓰면서 그때그때 하려고 합니다.
워낙 귀찮은 일이라서 ㅎㅎ

{ ... } 중괄호 한쌍으로 감싸는 형태 안에는 보통 functions, Else, Loop,등이 수용되며 별도 명령없이 문단의 차례가 되면 실행되고 조건부로 실행도중에 지정한 라인으로 튀어 나갈수 있다.  
AutoTrim 변수대입 형태 "Var1 = %Var2%" 같은 경우의 실행에서 대입하는 문법에서 공백이나 탭의 형태를 지정하여 지시할 수 있다.
BlockInput 비활성/활성을 결정한다.
주로 입력장치 마우스,키보드,등을 무호화 하는데 사용된다.
Break 반복명령을 종료하는데 주로 loop.같은 명령을 제어할 때는 루프 내에서만 유효하다.
Click 클릭은 클릭의 의미인데,숫자로 지정한 좌표를 클릭한 결과를 내거나 휠을 돌리는 결과를 내거나 등의 다양한 결과를 내는 명령이다.
ClipWait 여러 가지 데이터를 획득한후 윈도의 실제 크립보드에 입력이 완료될 때까지 기다린다.
Waits until the 
clipboard contains data.
Continue 반복명령 loop 를 수행할 때 다음명령어를 무시하고 처음 loop 로 돌아간다.
Control Makes a variety of changes to a control.
여러 가지 명령어임
ControlClick 실행중에 컨트롤에 마우스 이벤트나 휠이벤트를 보낸다.
ControlFocus 입력포커스를 윈도가 지정한 콘트롤로 전환한다.  
ControlGet 컨트롤 정보를 획득한다.
ControlGetFocus 윈도 컨트롤에서 사용되는 포커스를 찾는다
ControlGetPos 컨트롤 정보 위치,크기등을 찾는다.
ControlGetText 컨트롤에서 텍스트를 획득한다.
ControlMove 컨트롤 크기를 변경한다l.
ControlSend / ControlSendRaw Sends simulated keystrokes to a window or control.
ControlSetText Changes the text of a control.
CoordMode Sets coordinate mode for various commands to be relative to either the active window or the screen.
Critical Prevents the current thread from being interrupted by other threads.
DetectHiddenText Determines whether invisible text in a window is "seen" for the purpose of finding the window. This affects commands such as IfWinExist and WinActivate.
DetectHiddenWindows Determines whether invisible windows are "seen" by the script.
DllCall() Calls a function inside a DLL, such as a standard Windows API function.
Drive Ejects/retracts the tray in a CD or DVD drive, or sets a drive's volume label.
DriveGet Retrieves various types of information about the computer's drive(s).
DriveSpaceFree Retrieves the free disk space of a drive, in Megabytes.
Edit Opens the current script for editing in the associated editor.
Else Specifies the command(s) to perform if an IF-statement evaluates to FALSE. When more than one command is present, enclose them in a block (braces).
EnvAdd Sets a variable to the sum of itself plus the given value (can also add or subtract time from a date-time value). Synonymous with: var += value
EnvDiv Sets a variable to itself divided by the given value. Synonymous with: var /= value
 


EnvGet Retrieves an environment variable.
EnvMult Sets a variable to itself times the given value. Synonymous with: var *= value
EnvSet Writes a value to a variable contained in the environment.
EnvSub Sets a variable to itself minus the given value (can also compare date-time values). Synonymous with: var -= value
EnvUpdate Notifies the OS and all running applications that environment variable(s) have changed.
Exit Exits the current thread or (if the script is not persistent and contains no hotkeys) the entire script.
ExitApp Terminates the script unconditionally.
FileAppend Writes text to the end of a file (first creating the file, if necessary).
FileCopy Copies one or more files.
FileCopyDir Copies a folder along with all its sub-folders and files (similar to xcopy).
FileCreateDir Creates a folder.
FileCreateShortcut Creates a shortcut (.lnk) file.
FileDelete Deletes one or more files.
FileInstall Includes the specified file inside the compiled version of the script.
FileGetAttrib Reports whether a file or folder is read-only, hidden, etc.
FileGetShortcut Retrieves information about a shortcut (.lnk) file, such as its target file.
FileGetSize Retrieves the size of a file.
FileGetTime Retrieves the datetime stamp of a file or folder.
FileGetVersion Retrieves the version of a file.
FileMove Moves or renames one or more files.
FileMoveDir Moves a folder along with all its sub-folders and files. It can also rename a folder.
FileRead Reads a file's contents into a variable.
FileReadLine Reads the specified line from a file and stores the text in a variable.
FileRecycle Sends a file or directory to the recycle bin, if possible.
FileRecycleEmpty Empties the recycle bin.
FileRemoveDir Deletes a folder.
FileSelectFile Displays a standard dialog that allows the user to open or save file(s).
FileSelectFolder

Displays a standard dialog that allows the user to select a folder.

FileSetAttrib Changes the attributes of one or more files or folders. Wildcards are supported.
FileSetTime Changes the datetime stamp of one or more files or folders. Wildcards are supported.
FormatTime Transforms a YYYYMMDDHH24MISS timestamp into the specified date/time format.
GetKeyState Checks if a keyboard key or mouse/joystick button is down or up. Also retrieves joystick status.
Gosub Jumps to the specified label and continues execution until Return is encountered.
Goto Jumps to the specified label and continues execution.
GroupActivate Activates the next window in a window group that was defined with GroupAdd.
GroupAdd Adds a window specification to a window group, creating the group if necessary.
GroupClose Closes the active window if it was just activated by GroupActivate or GroupDeactivate. It then activates the next window in the series. It can also close all windows in a group.
GroupDeactivate Similar to GroupActivate except activates the next window not in the group.
GUI Creates and manages windows and controls. Such windows can be used as data entry forms or custom user interfaces.
GuiControl Makes a variety of changes to a control in a GUI window.
GuiControlGet Retrieves various types of information about a control in a GUI window.
HideAutoItWin, On|Off [Obsolete -- the following is equivalent: Menu, tray, NoIcon|Icon]
Hotkey Creates, modifies, enables, or disables a hotkey while the script is running.
if Specifies the command(s) to perform if the comparison of a variable to a value evalutes to TRUE. When more than one command is present, enclose them in a block (braces).
if (expression) Specifies the command(s) to perform if an expression evaluates to TRUE.
If var [not] between Checks whether a variable's contents are numerically or alphabetically between two values (inclusive).
If var [not] in/contains MatchList Checks whether a variable's contents match one of the items in a list.
 
If var is [not] type
Checks whether a variable's contents are numeric, uppercase, etc.
IfEqual/IfNotEqual
Compares a variable to a value for equality. Synonymous with: if var = value | if var <> value
IfExist / FileExist() 
Checks for the existence of a file or folder.
IfGreater/IfGreaterOrEqual
Compares a variable to a value. Synonymous with: if var > value | if var >= value
IfInString / InStr() 
Checks if a variable contains the specified string.
IfLess/IfLessOrEqual
Compares a variable to a value. Synonymous with: if var < value | if var <= value
IfMsgBox
Checks which button was pushed by the user during the most recent MsgBox command.
IfWinActive / IfWinNotActive
Checks if the specified window exists and is currently active (foremost).
IfWinExist / IfWinNotExist
Checks if the specified window exists.
ImageSearch Searches a region of the screen for an image.
IniDelete Deletes a value from a standard format .ini file.
IniRead Reads a value from a standard format .ini file.
IniWrite Writes a value to a standard format .ini file.
Input Waits for the user to type a string (not supported on Windows 9x: it does nothing).
InputBox Displays an input box to ask the user to enter a string.
KeyHistory Displays script info and a history of the most recent keystrokes and mouse clicks.
KeyWait Waits for a key or mouse/joystick button to be released or pressed down.
LeftClick [Obsolete -- use Click for greater flexibility]
LeftClickDrag [Obsolete -- use MouseClickDrag for greater flexibility]
ListHotkeys Displays the hotkeys in use by the current script, whether their subroutines are currently running, and whether or not they use the keyboard or mouse hook.
ListLines Displays the script lines most recently executed.
ListVars Displays the script's variables: their names and current contents.
Loop (normal) Perform a series of commands repeatedly: either the specified number of times or until break is encountered.
Loop (files & folders) Retrieves the specified files or folders, one at a time.
Loop (parse a string) Retrieves substrings (fields) from a string, one at a time.
Loop (read file contents) Retrieves the lines in a text file, one at a time (performs better than FileReadLine).
Loop (registry) Retrieves the contents of the specified registry subkey, one item at a time.
Menu Creates, deletes, modifies and displays menus and menu items. Changes the tray icon and its tooltip. Controls whether the main window of a compiled script can be opened.
MouseClick Clicks or holds down a mouse button, or turns the mouse wheel. NOTE: The Click command is generally more flexible and easier to use.
MouseClickDrag Clicks and holds the specified mouse button, moves the mouse to the destination coordinates, then releases the button.
MouseGetPos Retrieves the current position of the mouse cursor, and optionally which window and control it is hovering over.
MouseMove Moves the mouse cursor.
MsgBox Displays the specified text in a small window containing one or more buttons (such as Yes and No).
OnExit Specifies a subroutine to run automatically when the script exits.
OnMessage() Specifies a function to call automatically when the script receives the specified message.
OutputDebug Sends a string to the debugger (if any) for display.
Pause Pauses the script's current thread.
PixelGetColor Retrieves the color of the pixel at the specified x,y coordinates.
PixelSearch Searches a region of the screen for a pixel of the specified color.
PostMessage Places a message in the message queue of a window or control.
Process Performs one of the following operations on a process: checks if it exists; changes its priority; closes it; waits for it to close.
Progress Creates or updates a window containing a progress bar.
Random Generates a pseudo-random number.
RegExMatch() Determines whether a string contains a pattern (regular expression).
RegExReplace() Replaces occurrences of a pattern (regular expression) inside a string.
RegDelete Deletes a subkey or value from the registry.
RegRead Reads a value from the registry.
RegWrite Writes a value to the registry.
RegisterCallback() Creates a machine-code address that when called, redirects the call to a function in the script.
Reload Replaces the currently running instance of the script with a new one.
Repeat…EndRepeat
[Obsolete -- use Loop for greater flexibility]
Return Returns from a subroutine to which execution had previously jumped via function-call, Gosub, Hotkey activation, GroupActivate, or other means.
RightClick [Obsolete -- use Click for greater flexibility]
RightClickDrag [Obsolete -- use MouseClickDrag for greater flexibility]
Run Runs an external program.
RunAs Specifies a set of user credentials to use for all subsequent uses of Run and RunWait. Requires Windows 2000/XP or later.
RunWait Runs an external program and waits until it finishes.
Send / SendRaw 
SendInput /SendPlay
Sends simulated keystrokes and mouse clicks to the active window.
SendMessage Sends a message to a window or control and waits for acknowledgement.
SendMode Makes Send synonymous with SendInput or SendPlay rather than the default (SendEvent). Also makes Click and MouseMove/Click/Drag use the specified method.
SetBatchLines Determines how fast a script will run (affects CPU utilization).
SetCapslockState Sets the state of the Capslock key. Can also force the key to stay on or off.
SetControlDelay Sets the delay that will occur after each control-modifying command.
SetDefaultMouseSpeed Sets the mouse speed that will be used if unspecified in Click and MouseMove/Click/Drag.
SetEnv (Var = Value) Assigns the specified value to a variable.
SetFormat Sets the format of integers and floating point numbers generated by math operations.
SetKeyDelay Sets the delay that will occur after each keystroke sent by Send or ControlSend.
SetMouseDelay Sets the delay that will occur after each mouse movement or click.
SetNumlockState Sets the state of the Numlock key. Can also force the key to stay on or off.
SetScrollLockState Sets the state of the Scrolllock key. Can also force the key to stay on or off.
 
SetStoreCapslockMode
Whether to restore the state of CapsLock after a Send.
SetTimer Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
SetTitleMatchMode Sets the matching behavior of the WinTitle parameter in commands such as WinWait.
SetWinDelay Sets the delay that will occur after each windowing command, such as WinActivate.
SetWorkingDir Changes the script's current working directory.
Shutdown Shuts down, restarts, or logs off the system.
Sleep Waits the specified amount of time before continuing.
Sort Arranges a variable's contents in alphabetical, numerical, or random order (optionally removing duplicates).
SoundBeep Emits a tone from the PC speaker.
SoundGet Retrieves various settings from a sound device (master mute, master volume, etc.)
SoundGetWaveVolume Retrieves the wave output volume from a sound device.
SoundPlay Plays a sound, video, or other supported file type.
SoundSet Changes various settings of a sound device (master mute, master volume, etc.)
SoundSetWaveVolume Changes the wave output volume for a sound device.
SplashImage Creates or updates a window containing a JPG, GIF, or BMP image.
SplashTextOn Creates a customizable text popup window.
SplashTextOff Closes the above window.
SplitPath Separates a file name or URL into its name, directory, extension, and drive.
StatusBarGetText Retrieves the text from a standard status bar control.
StatusBarWait Waits until a window's status bar contains the specified string.
StringCaseSense Determines whether string comparisons are case sensitive (default is "not case sensitive").
StringGetPos / InStr() Retrieves the position of the specified substring within a string.
StringLeft Retrieves a number of characters from the left-hand side of a string.
StringLen / StrLen() Retrieves the count of how many characters are in a string.
StringLower Converts a string to lowercase.
 


StringMid / SubStr() Retrieves one or more characters from the specified position in a string.
StringReplace Replaces the specified substring with a new string.
StringRight Retrieves a number of characters from the right-hand side of a string.
StringSplit Separates a string into an array of substrings using the specified delimiters.
StringTrimLeft Removes a number of characters from the left-hand side of a string.
StringTrimRight Removes a number of characters from the right-hand side of a string.
StringUpper Converts a string to uppercase.
Suspend Disables or enables all or selected hotkeys and hotstrings.
SysGet Retrieves screen resolution, multi-monitor info, dimensions of system objects, and other system properties.
Thread Sets the priority or interruptibility of threads. It can also temporarily disable all timers.
ToolTip Creates an always-on-top window anywhere on the screen.
Transform Performs miscellaneous math functions, bitwise operations, and tasks such as ASCII/Unicode conversion.
TrayTip Creates a balloon message window near the tray icon. Requires Windows 2000/XP or later.
UrlDownloadToFile Downloads a file from the Internet.
Var = value Assigns the specified value to a variable.
Var := expression Evaluates an expression and stores the result in a variable.
VarSetCapacity() Enlarges a variable's holding capacity or frees its memory. Normally, this is necessary only for unusual circumstances such as DllCall.
While-loop Performs a series of commands repeatedly until the specified expression evaluates to false.
WinActivate Activates the specified window (makes it foremost).
WinActivateBottom Same as WinActivate except that it activates the bottommost (least recently active) matching window rather than the topmost.
WinClose Closes the specified window.
WinGetActiveStats Combines the functions of WinGetActiveTitle and WinGetPos into one command.
WinGetActiveTitle Retrieves the title of the active window.
WinGetClass Retrieves the specified window's class name.
WinGet Retrieves the specified window's unique ID, process ID, process name, or a list of its controls. It can also retrieve a list of all windows matching the specified criteria.
WinGetPos Retrieves the position and size of the specified window.
WinGetText Retrieves the text from the specified window.
WinGetTitle Retrieves the title of the specified window.
WinHide Hides the specified window.
WinKill Forces the specified window to close.
WinMaximize Enlarges the specified window to its maximum size.
WinMenuSelectItem Invokes a menu item from the menu bar of the specified window.
WinMinimize Collapses the specified window into a button on the task bar.
WinMinimizeAll Minimizes all windows.
WinMinimizeAllUndo Reverses the effect of a previous WinMinimizeAll.
WinMove Changes the position and/or size of the specified window.
WinRestore Unminimizes or unmaximizes the specified window if it is minimized or maximized.
WinSet Makes a variety of changes to the specified window, such as "always on top" and transparency.
WinSetTitle Changes the title of the specified window.
WinShow Unhides the specified window.
WinWait Waits until the specified window exists.
WinWaitActive Waits until the specified window is active.
WinWaitClose Waits until the specified window does not exist.
WinWaitNotActive Waits until the specified window is not active.
#AllowSameLineComments Only for AutoIt v2 (.aut) scripts: Allows a comment to appear on the same line as a command.
#ClipboardTimeout Changes how long the script keeps trying to access the clipboard when the first attempt fails.
#CommentFlag Changes the script's comment symbol from semicolon to some other string.
#ErrorStdOut Sends any syntax error that prevents a script from launching to stdout rather than displaying a dialog.
#EscapeChar Changes the script's escape character (for example: backslash vs. accent).
 
#HotkeyInterval Along with #MaxHotkeysPerInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.
#HotkeyModifierTimeout Affects the behavior of hotkey modifiers: CTRL, ALT, WIN, and SHIFT.
#Hotstring Changes hotstring options or ending characters.
#IfWinActive / #IfWinExist Creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists.
#Include Causes the script to behave as though the specified file's contents are present at this exact position.
#InstallKeybdHook Forces the unconditional installation of the keyboard hook.
#InstallMouseHook Forces the unconditional installation of the mouse hook.
#KeyHistory Sets the maximum number of keyboard and mouse events displayed by the KeyHistory window. You can set it to 0 to disable key history.
#MaxHotkeysPerInterval Along with #HotkeyInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.
#MaxMem Sets the maximum capacity of each variable to the specified number of megabytes.
#MaxThreads Sets the maximum number of simultaneous threads.
#MaxThreadsBuffer Causes some or all hotkeys to buffer rather than ignore keypresses when their #MaxThreadsPerHotkey limit has been reached.
#MaxThreadsPerHotkey Sets the maximum number of simultaneous threads per hotkey or hotstring.
#NoEnv Avoids checking empty variables to see if they are environment variables (recommended for all new scripts).
#NoTrayIcon Disables the showing of a tray icon.
#Persistent Keeps a script permanently running (that is, until the user closes it or ExitApp is encountered).
#SingleInstance Determines whether a script is allowed to run again when it is already running.
#UseHook Forces the use of the hook to implement all or some keyboard hotkeys.
#WinActivateForce Skips the gentle method of activating a window and goes straight to the forceful method.


오토핫키 그초보예제
오토핫키 왕초보 (2)

오토핫키명령어 바로가기
오토핫키 실행문서 만들기

     



반응형

'소프트웨어 > 스크립트천국' 카테고리의 다른 글

복사금지 해제  (1) 2012.01.07
동영상 음악 자동실행  (1) 2011.10.03
핑-트레이스 툴  (0) 2011.06.03
동영상 자르기  (1) 2011.06.03
오토핫키 왕초보(3)  (2) 2011.01.29
유용한 금지태그 모음  (0) 2010.10.16
오토핫키 왕초보 첫걸음  (5) 2010.07.12
오토핫키 명령어  (4) 2010.07.07
최신 드라이버 탐지 소프트웨어  (1) 2010.06.19
자막제작 편집 프로그램  (0) 2010.06.19