Easy하게 Fun하게 오토핫키를 배워보자
1. 참고자료
가. 지난 세미나 강의 자료
나. 오토핫키 고수의 강좌
다. 오토핫키 샘플 자료 저장소
2. 설치 및 세팅 작업
가. 오토핫키 설치
나. 통합개발환경 및 한글 패치
다. 업데이트 오류 해결
옵션- Open User Options File 선택후 에디터에 화일이 열리면 아래의 필요한 내용을 끝에 추가시켜준다
복수 에디터창 열기 -> 이 셋팅을 0으로 하면 창을 복수로 열수있으나 디버그 모드나 기타 확장기능들을 사용할수 없다
check.if.already.open=0
자동업데이트 금지 홈페이지 다운으로 업데이트 에러가 반복되는 경우 방
3. 프로그래밍 언어 기본 요소
•
알고리즘의 기본 구조
◦
순차 구조: 처리할 일들을 순서대로 나열한 구조
◦
선택 구조: 여러 가지 조건 중 한 가지를 선택하여 처리하는 구조
◦
반복 구조: 반복적으로 수행하는 일을 표현하는 구조
** 반복을 벗어날 수 있는 조건을 반드시 정해 주어야 한다.
graph LR P1[(Variable)] --- Function --- P2{IF} --- P3((While/Loop)) --- Line_by_Line Line_by_Line --- P1[(Variable)]
Mermaid
복사
변수(통 만들기)
graph LR P1[(Variable)]:::yellow --- Function --- P2{IF} --- P3((While/Loop)) --- Line_by_Line Line_by_Line --- P1[(Variable)] %% Colors %% classDef red fill: #FF9898, stroke: black, stroke-width: 2px, color: white classDef blue fill: #336EFF, stroke: black, stroke-width: 2px, color: white classDef orange fill: #C70039, stroke: black, stroke-width: 2px, color: white classDef yellow fill: #FFC300, stroke: black, stroke-width: 2px, color: white classDef green fill: #16B552, stroke: black, stroke-width: 2px, color: white classDef magenta fill: magenta, stroke: black, stroke-width: 2px, color: white
Mermaid
복사
•
통에 값을 어떻게 넣을 것인가?
변수(variable)는 값을 담는 통이다.
정의하는 방법은
변수 이름 := 변수 값
예를 들면
수박통 :=3 라고 정의하면, 수박통에 3이라는 값이 들어있다고 말할 수 있다.
•
통에 있는 값을 어떻게 꺼낼 것인가?
변수(값이 들어있는 통)에 있는 변수 값을 이용할 때는
% 변수 이름 이라고 정의한다.
예를 들면
수박통 안에 들어 있는 3이라는 수를 이용하고 싶을 때는
% 수박통이라고 쓰고 사용한다.
사과박스 := 100
귤박스 := 50
MsgBox, % 사과박스
MsgBox, % 귤박스
C++
복사
함수(능력자 만들기)
graph LR P1[(Variable)] --- Function:::yellow --- P2{IF} --- P3((While/Loop)) --- Line_by_Line Line_by_Line --- P1[(Variable)] %% Colors %% classDef red fill: #FF9898, stroke: black, stroke-width: 2px, color: white classDef blue fill: #336EFF, stroke: black, stroke-width: 2px, color: white classDef orange fill: #C70039, stroke: black, stroke-width: 2px, color: white classDef yellow fill: #FFC300, stroke: black, stroke-width: 2px, color: white classDef green fill: #16B552, stroke: black, stroke-width: 2px, color: white classDef magenta fill: magenta, stroke: black, stroke-width: 2px, color: white
Mermaid
복사
//함수 호출하는 부분
함수명(입력값)
//함수 선언하는 부분
함수명(입력값)
{
처리 내용
}
C++
복사
슈퍼맨목적지 := "서울"
배트맨목적지 := "부산"
superman(슈퍼맨목적지)
batman(배트맨목적지)
김프로쌤()
superman(슈퍼맨목적지)
{
MsgBox, 넵! 슈퍼맨이 바로 %슈퍼맨목적지%로 가겠습니다.
}
batman(배트맨목적지)
{
MsgBox, 넵! 배트맨은 바로 %배트맨목적지%로 가겠습니다.
}
김프로쌤()
{
MsgBox, 김프로쌤은 목적지가 없어요. 그냥 영신여고에 있어야겠습니다.
}
C++
복사
if(선택의 시간)
graph LR P1[(Variable)] --- Function --- P2{IF}:::yellow --- P3((While/Loop)) --- Line_by_Line Line_by_Line --- P1[(Variable)] %% Colors %% classDef red fill: #FF9898, stroke: black, stroke-width: 2px, color: white classDef blue fill: #336EFF, stroke: black, stroke-width: 2px, color: white classDef orange fill: #C70039, stroke: black, stroke-width: 2px, color: white classDef yellow fill: #FFC300, stroke: black, stroke-width: 2px, color: white classDef green fill: #16B552, stroke: black, stroke-width: 2px, color: white classDef magenta fill: magenta, stroke: black, stroke-width: 2px, color: white
Mermaid
복사
if(조건1)
{
조건1을 만족할 때 실행할 코드
}
else if(조건2)
{
조건2를 만족할 때 실행할 코드
}
else
{
조건1과 조건2 이외의 조건에서 실행할 코드
}
C
복사
좀비전투력 := 100
생존자전투력 := 50
if(좀비전투력 > 생존자전투력)
{
도망(좀비전투력, 생존자전투력) //함수 호출
} else
{
전투(좀비전투력, 생존자전투력) //함수 호출
}
전투(좀비전투력, 생존자전투력)
{
MsgBox, 생존자의 전투력이 %생존자전투력%, 좀비의 전투력이 %좀비전투력%. 전투~
}
도망(좀비전투력, 생존자전투력)
{
MsgBox, 생존자의 전투력이 %생존자전투력%, 좀비의 전투력이 %좀비전투력%. 도망~
}
C++
복사
Loop(반복)
graph LR P1[(Variable)] --- Function --- P2{IF} --- P3((While/Loop)):::yellow --- Line_by_Line Line_by_Line --- P1[(Variable)] %% Colors %% classDef red fill: #FF9898, stroke: black, stroke-width: 2px, color: white classDef blue fill: #336EFF, stroke: black, stroke-width: 2px, color: white classDef orange fill: #C70039, stroke: black, stroke-width: 2px, color: white classDef yellow fill: #FFC300, stroke: black, stroke-width: 2px, color: white classDef green fill: #16B552, stroke: black, stroke-width: 2px, color: white classDef magenta fill: magenta, stroke: black, stroke-width: 2px, color: white
Mermaid
복사
Loop, 횟수
{
반복할 코드
}
C
복사
a := 100
b := 50
c := 3
if(a > b) {
Loop, % c
{
MsgBox, % a
}
} else {
Loop, % c
{
MsgBox, % b
}
}
C++
복사
나의주사위수 := 1
친구주사위수 := 6
반복횟수 := 0
if(나의주사위수 > 친구주사위수) {
Loop, % 나의주사위수 {
나의말()
}
} else {
Loop, % 친구주사위수 {
친구말()
}
}
나의말() {
MsgBox, 나의 말 점프
}
친구말() {
MsgBox, 친구 말의 점프
}
C++
복사
코딩 실전
GUI와의 결합
Gui, Add, Text, x10 y10 w150 h20, 표시하고 싶은 내용
Gui, Add, Button, x10 y30 w150 h20, 시작
Gui, Add, Button, x10 y55 w150 h20, 종료
Gui, Show,, 프로그램 이름 적는 곳
return
Button시작:
{
MsgBox, 시작 버튼을 누르면 보여지는 부분
}
return
Button종료:
{
ExitApp
}
return
GuiClose:
{
ExitApp
}
return
/*
GuiClose의 경우에는
*GuiClose:
*ExitApp
으로 약식 표기하기도 함
*/
C++
복사
단계
/* #####################################
* 반복문인 Loop을 연습할 수 있는 코드입니다.
* ########################################
*/
F1::
Loop, 3
{
MsgBox, Iteration number is %A_Index%. ; A_Index will be 1, 2, then 3
Sleep, 100
}
return
F2::
Loop
{
if (A_Index > 25)
break ; Terminate the loop
if (A_Index < 20)
continue ; Skip the below and start a new iteration
MsgBox, A_Index = %A_Index% ; This will display only the numbers 20 through 25
}
return
F3::
Loop, 3
{
Sleep, 1000
MsgBox, Text
}
Return
F4::
Count=3
Stop=2000
Loop, %Count%
{
MsgBox, Text
Sleep, Stop
}
Return
C++
복사
단계
/* ################################################################
* InputBox, If statement, Loop, MsgBox를 응용한 커피 자판기 프로그램
* ################################################################
*/
InputBox, yourMoney, Coffee Machine, Please put your money in: , , 300, 150
coffeePrice := 500
if (yourMoney < coffeePrice) {
MsgBox %coffeePrice% %yourMoney%
MsgBox, You need more money to get a cup of coffee. Sorry.
ExitApp
}
cupsCount := yourMoney // coffeePrice
change := Mod(yourMoney, coffeePrice)
Loop, %cupsCount%
{
MsgBox, Coffee %A_Index%`n
}
MsgBox, Here's your change %change%
return
C++
복사
단계
/* ################################################################
* 저장과 초기화를 연습할 수 있는 간단한 메모장 프로그램
* ################################################################
*/
Gui, Add, Text, x22 y9 w320 h40 , Keep your beautiful memories safe for good with us.
Gui, Add, Edit, r10 x12 y59 w330 h150 vTxtEdit, Write something below
Gui, Add, Button, x12 y219 w160 h60 gBtnSave, Save
Gui, Add, Button, x182 y219 w160 h60 gBtnReset, Reset
Gui, Show, w354 h294, My beautiful Memories
return
GuiClose:
ExitApp
BtnSave: ;메모 내용을 텍스트 파일에 계속 추가하는 부분
Gui, Submit, NoHide
FileAppend, %TxtEdit%, memories.txt
return
BtnReset: ;입력하고 있는 메모 내용을 모두 지워주는 부분
guicontrol,, TxtEdit,
return
C++
복사
#SingleInstance force
#NoEnv
;----------------------------------------------------------------------------------- set gui
Gui, Add, GroupBox, w490 h123 cED006D vGroup1, 1. CheckBox and Radio
Gui, Add, Checkbox, xs+5 yp+25 vCheck1 gCheck1Action, 체크박스 1
Gui, Add, Checkbox, x+20 yp vCheck2 gCheck2Action, 체크박스 2
Gui, Add, Checkbox, x+20 yp Right vCheck3 Checked, 체크박스 3 (오른쪽 위치, 구동 시 체크상태)
Gui, Add, Radio, xs+5 y+15 gRadioGroup1 vRadioGroup1, 라디오 1-1 (기본)
Gui, Add, Radio, x+20 yp gRadioGroup1, 라디오 1-2
Gui, Add, Radio, x+20 yp gRadioGroup1 Right , 라디오 1-3 (오른쪽)
Gui, Add, Text, xs+5 y+10 c1266FF, ---------------------------------그룹 나누기------------------------------------
Gui, Add, Radio, xs+5 yp+20 gRadioGroup2 vRadioGroup2, 라디오 2-1 (기본)
Gui, Add, Radio, x+20 yp gRadioGroup2, 라디오 2-2
Gui, Add, Radio, x+20 yp gRadioGroup2 Right, 라디오 2-3 (오른쪽)
Gui, Add, Button, x+15 yp gBT1, 선택 결과 확인
Gui, Add, GroupBox, xs y+15 w490 h155 cED006D vGroup2, 2. DropDownList, Combobox, ListBox
Gui, Add, Text, xs+5 yp+30 c1266FF, DropDownList:
Gui, Add, DropDownList, x+30 yp-4 vDrop1 gDrop1Action, Select BG color||Red|Green|Blue|Black|Yellow
Gui, Add, DropDownList, x+30 yp vDrop2, Select City||서울|뉴욕|런던|파리|로마|이스탄불
Gui, Add, Text, xs+5 yp+35 c1266FF, Combobox:
Gui, Add, ComboBox, x+46 yp-4 vCombo1, Red|Green|Blue|Black|Yellow
Gui, Add, Button, x+30 yp-2 gBT2, 보기
Gui, Add, Text, xs+5 y+5 cpurple, < 기타 purple, white 등 기본컬러 또는 RGB 6자리 코드(000000=black) 입력, [보기] >
Gui, Add, Text, xs+5 yp+30 c1266FF, ListBox:
Gui, Add, ListBox, x+66 yp-4 vList1, Red|Green|Blue|Black|Yellow
Gui, Add, Button, x+30 yp+17 gBT3, 보기
Gui, Add, Button, x+72 yp gBT4, 선택 결과 확인
Gui, Add, GroupBox, xs y+15 w490 h97 cED006D vGroup3, 3. Progress and Slider
Gui, Add, Text, xs+5 yp+30 c1266FF, Slider:
Gui, Add, Slider, x+40 yp-4 w320 Tickinterval10 gSlider1 altsubmit vSlider1
Gui, Add, Text, x+8 yp+6 c1266FF Left vNslider, 먼저 선택
Gui, Add, Text, xs+5 yp+40 c1266FF, Progress:
Gui, Add, Progress, x+20 yp-4 w320 h20 c1266FF BackgroundC6C6C6 Range0-100 vProgress1
Gui, Add, Text, x+10 yp+6 c1266FF w20 Left vNprogress, 100
Gui, Add, Button, x+15 yp-7 gBT5, 시작
Gui, Show,, [쉬운 오토핫키 강좌] 10. Gui 활용 - Add와 ControlType
return
GuiClose:
exitapp
;----------------------------------------------------------------------------------- subroutine 1
Check1Action:
Gui, Submit, NoHide
if Check1=1
GuiControl,, Group1, vGroup1: gCheck1Action- (1)번 체크
else
GuiControl,, Group1, vGroup1: gCheck1Action- (1)번 체크 해제
return
Check2Action:
Gui, Submit, NoHide
if Check2=1
GuiControl,, Group1, vGroup1: gCheck2Action- (2)번 체크
else
GuiControl,, Group1, vGroup1: gCheck2Action- (2)번 체크 해제
return
RadioGroup1:
Gui, Submit, NoHide
GuiControl,, Group1, gRadioGroup1- 1그룹의 %RadioGroup1%번 radio 선택
return
RadioGroup2:
Gui, Submit, NoHide
GuiControl,, Group1, gRadioGroup2- 2그룹의 %RadioGroup2%번 radio 선택
return
BT1:
Gui, Submit, NoHide
GuiControl,, Group1, 선택결과: Check1(%Check1%), Check2(%Check2%), Check3(%Check3%), RadioGroup1(%RadioGroup1%), RadioGroup2(%RadioGroup2%)
return
;----------------------------------------------------------------------------------- subroutine 2-1
Drop1Action:
Gui, Submit, NoHide ; Gui의 값을 이용하기 위해서는 필수적인 명령줄입니다.
;MsgBox % Drop1 ", " Drop2 ; 활성화 해서 확인해 보세요
GuiControl,, Group2, vGroup2: gDrop1Action - %Drop1% 을 선택했군요...
if (Drop1="Red") {
textcolor=yellow
} else if (Drop1="Green") {
textcolor=white
} else if (Drop1="Blue") {
textcolor=red
} else if (Drop1="Black") {
textcolor=yellow
} else if (Drop1="Yellow") {
textcolor=black
} else {
MsgBox 아무 것도 선택 안했어요
return
}
Gui, 2: Font, s10 bold
Gui, 2: Color, %Drop1% ; 바탕색
Gui, 2: Add, Text, c%textcolor%, 바탕색,글자색 확인 (2초 후 사라짐) ; 글자색
Gui, 2: Show, w250 h100, Gui 2
sleep, 2000
Gui, 2: Destroy ; gui 폭발!!
return
2GuiClose:
Gui, 2: Destroy
return
;----------------------------------------------------------------------------------- subroutine 2-2
BT2:
Gui, Submit, NoHide
if (Combo1="Red") {
textcolor=yellow
} else if (Combo1="Green") {
textcolor=white
} else if (Combo1="Blue") {
textcolor=red
} else if (Combo1="Black") {
textcolor=yellow
} else if (Combo1="Yellow") {
textcolor=black
}
Gui, 3: Font, s10 bold
Gui, 3: Color, %Combo1%
Gui, 3: Add, Text, c%textcolor%, 바탕색,글자색 확인 (2초 후 사라짐)
Gui, 3: Show, w250 h100, Gui 3
sleep, 2000
Gui, 3: Destroy
return
3GuiClose:
Gui, 3: Destroy
return
;----------------------------------------------------------------------------------- subroutine 2-3
BT3:
Gui, Submit, NoHide
if (List1="Red") {
textcolor=yellow
} else if (List1="Green") {
textcolor=white
} else if (List1="Blue") {
textcolor=red
} else if (List1="Black") {
textcolor=yellow
} else if (List1="Yellow") {
textcolor=black
} else {
MsgBox 아무 것도 선택 안했어요
return
}
Gui, 4: Font, s10 bold
Gui, 4: Color, %List1%
Gui, 4: Add, Text, c%textcolor%, 바탕색,글자색 확인 (2초 후 사라짐)
Gui, 4: Show, w250 h100, Gui 2
sleep, 2000
Gui, 4: Destroy
return
4GuiClose:
Gui, 4: Destroy
return
BT4:
Gui, Submit, NoHide
GuiControl,, Group2, 선택결과: Drop1(%Drop1%), Drop2(%Drop2%), Combo(%Combo1%), List(%List1%)
return
;----------------------------------------------------------------------------------- subroutine 3
Slider1:
Gui, Submit, NoHide
GuiControl,, Nslider, %Slider1%
return
BT5:
Gui, Submit, NoHide
N:=0
GuiControl,, Group3, vGroup3: 진행중....
Loop
{
N++
if (N>Slider1) {
break
}
GuiControl,, Progress1, %N%
GuiControl,, Nprogress, %N%
sleep, 50
}
GuiControl,, Group3, vGroup3: 끄~~읕
return
Python
복사
자신의 코딩 성장 스토리를 적어보자
•
활동내용
•
느낀 점
•
아쉬운 점
•
향후 계획