매크로

조회 수 656 추천 4 댓글 6


원문 http://knowledgeisfree.tistory.com/103

https://i.imgur.com/gXbe75N.png

예전에 프로그램 만들때 사용했던 마이크로소프트 오피스 gui 프로토타입입니다

초기때는 이미지 사용한 버전이라, 이미지 안쓰려고 전부다 프로그레스바로 바꾼 노가다의 흔적떄문에 눈물이 나네요

 

오토핫키L의 제작자 Lexikos가 1.1.20 버전부터 새로 추가한 기능인 BoundFunc을 코드내에서 사용하니

관심이 있다면 아래 코드를 통해 사용예를 확인해보시는것도 공부에 도움이 될 듯 합니다

 

코드 다운로드

 

코드에 주석달아서 더럽히는(...)걸 좋아하지 않아서 주석이 없지만 글작성하면서 아래에 적어두니 참고하시기 바랍니다

 

#SingleInstance, Off  ;프로그램 중복실행 허용
#NoEnv  ;내장환경변수 제거, 퍼포먼스 향샹 목적
#NoTrayIcon  ;트레이아이콘 제거
#KeyHistory;키저장기능 제거, 퍼포먼스 향샹 목적
ListLines Off  ;라인제거, 퍼포먼스 향샹 목적
SetWinDelay, 0  ;윈도우 관련 딜레이 최소한으로 설정 (-1은 딜레이X)
SetBatchLines, -1  ;코드간 자동 Sleep 삭제, 속도 향샹 목적

new OfficeGUI()
return

 

class OfficeGUI {

 

static GuiW := A_ScreenWidth * 0.3, GuiH := A_ScreenHeight * 0.6  ;시작 Static 변수 Assign

 

__New() {

 

this.Bound := []  ;오브젝트 생성
this.Bound.IconButton := this.IconButton.Bind(this)  ;이하 버튼 g라벨 초기 설정 구간
this.Bound.MinimizeButton := this.MinimizeButton.Bind(this)
this.Bound.MaximizeButton := this.MaximizeButton.Bind(this)
this.Bound.CloseButton := this.CloseButton.Bind(this)
this.Bound.MoveButton := this.MoveButton.Bind(this)
this.Color := "FFFFFF"  ;배경색 Assign

 

Gui, New, -DPIScale -Caption +Resize +hwndhMainWindow  ;구이 윈도우설정
this.hMainWindow := hMainWindow  ;클래스내 사용을위해 hwnd 설정

 

Gui, Margin, 0, 0  ;컴포넌트 간의 기본폭 삭제
Gui, Color, % this.Color  ;배경색 지정

 

; 아래는 BoundFunction 관련 코드 (도움말 http://ahkscript.org/docs/objects/Functor.htm)

Gui, Add, Text, % " x" 1 " y" 1 " w" 37 " h" 28 " +BackgroundTrans hwndhIconButton"  ; 아이콘 영역 설정
this.hIconButton := hIconButton  ;아이콘 hwnd 설정
BoundIconButton := this.Bound.IconButton  ;함수 바운드
GuiControl, +g, %hIconButton%, %BoundIconButton%  ;아이콘버튼 g라벨 바운드

 

Gui, Add, Text, % " x" this.GuiW-89 " y" 4 " w" 29 " h" 22 " +BackgroundTrans hwndhMinimizeButton" ;최소화 영역 설정
this.hMinimizeButton := hMinimizeButton  ;최소화 hwnd 설정
BoundMinimizeButton := this.Bound.MinimizeButton  ;함수 바운드
GuiControl, +g, %hMinimizeButton%, %BoundMinimizeButton%  ;최소화버튼 g라벨 바운드

 

Gui, Add, Text, % " x" this.GuiW-59 " y" 4 " w" 29 " h" 22 " +BackgroundTrans hwndhMaximizeButton"  ;최대화  영역
this.hMaximizeButton := hMaximizeButton  ;최대화 hwnd 설정
BoundMaximizeButton := this.Bound.MaximizeButton  ;함수 바운드
GuiControl, +g, %hMaximizeButton%, %BoundMaximizeButton%  ;최대화버튼 g라벨 바운드

 

Gui, Add, Text, % " x" this.GuiW-30 " y" 4 " w" 29 " h" 22 " +BackgroundTrans hwndhCloseButton"  ;종료 (X) 영역
this.hCloseButton := hCloseButton  ;종료 hwnd 설정
BoundClose := this.Bound.CloseButton  ;함수바운드
GuiControl, +g, %hCloseButton%, %BoundClose%  ;종료버튼 g라벨 바운드

 

Gui, Add, Text, % " x" 1 " y" 1 " w" this.GuiW-2 " h" 28 " +BackgroundTrans hwndhMoveButton"  ;상단바  영역
this.hMoveButton := hMoveButton  ;hwnd 설정
BoundMoveButton := this.Bound.MoveButton  ;함수바운드
GuiControl, +g, %hMoveButton%, %BoundMoveButton%  ;상단 드래그영역 g라벨 바운드

 

;이제부터는 Progrss를 이용한 버튼이미지 그리기 부분

Gui, Add, Progress, % " x" 11 " y" 4 " w" 16 " h" 16 " Background0072C6", 0  ;GUI 아이콘

Gui, Add, Progress, % " x" this.GuiW-80 " y" 10 " w" 9 " h" 2 " Background777777 hwndhMin", 0  ;GUI MINIMIZE

Gui, Add, Progress, % " x" this.GuiW-50 " y" 3 " w" 11 " h" 2 " Background777777 hwndhMaxT", 0  ;GUI 최대화 top
Gui, Add, Progress, % " x" this.GuiW-50 " y" 11 " w" 11 " h" 2 " Background777777 hwndhMaxB", 0  ;GUI 최대화 bottom
Gui, Add, Progress, % " x" this.GuiW-41 " y" 3 " w" 2 " h" 10 " Background777777 hwndhMaxR", 0  ;GUI 최대화 right
Gui, Add, Progress, % " x" this.GuiW-50 " y" 3 " w" 2 " h" 10 " Background777777 hwndhMaxL", 0  ;GUI 최대화 left
  
Gui, Add, Progress, % " x" this.GuiW-20 " y" 4 " w" 1 " h" 1 " Background777777 hwndhXTL1", 0  ;GUI CLOSE TOP-LEFT 01
Gui, Add, Progress, % " x" this.GuiW-21 " y" 5 " w" 3 " h" 1 " Background777777 hwndhXTL2", 0  ;GUI CLOSE TOP-LEFT 02
Gui, Add, Progress, % " x" this.GuiW-20 " y" 6 " w" 3 " h" 1 " Background777777 hwndhXTL3", 0  ;GUI CLOSE TOP-LEFT 03
Gui, Add, Progress, % " x" this.GuiW-13 " y" 4 " w" 1 " h" 1 " Background777777 hwndhXTR1", 0  ;GUI CLOSE TOP-RIGHT 01
Gui, Add, Progress, % " x" this.GuiW-14 " y" 5 " w" 3 " h" 1 " Background777777 hwndhXTR2", 0  ;GUI CLOSE TOP-RIGHT 02
Gui, Add, Progress, % " x" this.GuiW-15 " y" 6 " w" 3 " h" 1 " Background777777 hwndhXTR3", 0  ;GUI CLOSE TOP-RIGHT 03
Gui, Add, Progress, % " x" this.GuiW-19 " y" 7 " w" 6 " h" 1 " Background777777 hwndhXC1", 0  ;GUI CLOSE CENTER 01
Gui, Add, Progress, % " x" this.GuiW-18 " y" 8 " w" 4 " h" 1 " Background777777 hwndhXC2", 0  ;GUI CLOSE CENTER 02
Gui, Add, Progress, % " x" this.GuiW-18 " y" 9 " w" 4 " h" 1 " Background777777 hwndhXC3", 0  ;GUI CLOSE CENTER 03
Gui, Add, Progress, % " x" this.GuiW-19 " y" 10 " w" 6 " h" 1 " Background777777 hwndhXC4", 0  ;GUI CLOSE CENTER 04
Gui, Add, Progress, % " x" this.GuiW-20 " y" 11 " w" 3 " h" 1 " Background777777 hwndhCBL1", 0  ;GUI CLOSE BOTTOM-LEFT 01
Gui, Add, Progress, % " x" this.GuiW-21 " y" 12 " w" 3 " h" 1 " Background777777 hwndhCBL2", 0  ;GUI CLOSE BOTTOM-LEFT 02
Gui, Add, Progress, % " x" this.GuiW-20 " y" 13 " w" 1 " h" 1 " Background777777 hwndhCBL3", 0  ;GUI CLOSE BOTTOM-LEFT 03
Gui, Add, Progress, % " x" this.GuiW-15 " y" 11 " w" 3 " h" 1 " Background777777 hwndhCBR1", 0  ;GUI CLOSE BOTTOM-RIGHT 01
Gui, Add, Progress, % " x" this.GuiW-14 " y" 12 " w" 3 " h" 1 " Background777777 hwndhCBR2", 0  ;GUI CLOSE BOTTOM-RIGHT 02
Gui, Add, Progress, % " x" this.GuiW-13 " y" 13 " w" 1 " h" 1 " Background777777 hwndhCBR3", 0  ;GUI CLOSE BOTTOM-RIGHT 03
Gui, Add, Progress, % " x" 1 " y" this.GuiH-23 " w" this.GuiW-2 " h" 22 " Background0072C6 hwndhBar", 0  ;GUI STATUSBAR


Gui, Font, s9 c444444, Segoe UI  ;프로그램 타이틀 텍스트를위해 폰트설정
Gui, Add, Text, % " x" 37 " y" 2 " w" this.GuiW-96 " +Center +BackgroundTrans hwndhTitletext", 프로그램 타이틀
Gui, Font  ;폰트 초기화


Gui, Font, s8 cFFFFFF, Segoe UI  ;하단 메시지 텍스트를위해 폰트설정
Gui, Add, Text, % " x" 8 " y" this.GuiH-19 " w" this.GuiW-16 " +BackgroundTrans hwndhBarText", 하단 메시지 텍스트
Gui, Font  ;폰트 초기화


WinEvents.Register(this.hMainWindow, this)  ;기본 GuiEvent 레지스트


Gui, Show, % " w" this.GuiW " h" this.GuiH, GUI

}

 

IconButton()  ;아이콘버튼, Bound된 g라벨 Function
{
    SendInput, !{Space}  ;컨트롤메뉴 보이게
}

 

MinimizeButton()  ;최소화버튼, Bound된 g라벨 Func
{
    WinMinimize
}

 

MaximizeButton()  ;최대화버튼, Bound된 g라벨 Func
{
    VarSetCapacity(rect, 16, 0)
    DllCall("GetClientRect", uint, this.hMainWindow, uint, &rect )  ;보더와 캡션을 제외한 실제 윈도우영역을 구함
    if (NumGet( rect, 8, "int" ) >= A_ScreenWidth - 50)
        WinRestore
   else
       WinMaximize
}

 

MoveButton() ;상단 드래그영역, Bound된 g라벨 Func
{
    PostMessage, 0xA1, 2,,, A  ;드래그
}

 

CloseButton()  ;종료 X버튼, Bound된 g라벨 Func
{
    this.Delete("Bound")  ;Bound 오브젝트 제거
    WinEvents.Unregister(this.hMainWindow)  ;기본 GuiEvent 설정 언로드
    Gui, Destroy
    ExitApp
}

 

GuiSize()  ;구이 리사이즈, WinEvents.Register(this.hMainWindow, this)로 인해 Bound됨
{
    global
    GuiControl, Move, % this.hMinimizeButton, % "x" A_GuiWidth - 89 " y" 4 " w" 29 " h" 22
    GuiControl, Move, % this.hMaximizeButton, % "x" A_GuiWidth - 59 " y" 4 " w" 29 " h" 22
    GuiControl, Move, % this.hCloseButton, % "x" A_GuiWidth - 29 " y" 4 " w" 29 " h" 22
    GuiControl, Move, % this.hMoveButton, % "x" 1 " y" 1 " w" A_GuiWidth - 2 " h" 28
    GuiControl, Move, % hMin, % "x" A_GuiWidth - 80 " y" 10 " w" 9 " h" 2
    GuiControl, Move, % hMaxT, % "x" A_GuiWidth - 50 "y" 3 "w" 11 "h" 2
    GuiControl, Move, % hMaxB, % "x" A_GuiWidth - 50 "y" 11 "w" 11 "h" 2
    GuiControl, Move, % hMaxR, % "x" A_GuiWidth - 41 "y" 3 "w" 2 "h" 10
    GuiControl, Move, % hMaxL, % "x" A_GuiWidth - 50 "y" 3 "w" 2 "h" 10
    GuiControl, Move, % hXTL1, % "x" A_GuiWidth - 20 " y" 4 " w" 1 " h" 1
    GuiControl, Move, % hXTL2, % "x" A_GuiWidth - 21 " y" 5 " w" 3 " h" 1
    GuiControl, Move, % hXTL3, % "x" A_GuiWidth - 20 " y" 6 " w" 3 " h" 1
    GuiControl, Move, % hXTR1, % "x" A_GuiWidth - 13 " y" 4 " w" 1 " h" 1
    GuiControl, Move, % hXTR2, % "x" A_GuiWidth - 14 " y" 5 " w" 3 " h" 1
    GuiControl, Move, % hXTR3, % "x" A_GuiWidth - 15 "y" 6 "w" 3 "h" 1
    GuiControl, Move, % hXC1, % "x" A_GuiWidth - 19 " y" 7 " w" 6 " h" 1
    GuiControl, Move, % hXC2, % "x" A_GuiWidth - 18 " y" 8 " w" 4 " h" 1
    GuiControl, Move, % hXC3, % "x" A_GuiWidth - 18 " y" 9 " w" 4 " h" 1
    GuiControl, Move, % hXC4, % "x" A_GuiWidth - 19 " y" 10 " w" 6 " h" 1
    GuiControl, Move, % hCBL1, % "x" A_GuiWidth - 20 " y" 11 " w" 3 " h" 1
    GuiControl, Move, % hCBL2, % "x" A_GuiWidth - 21 " y" 12 " w" 3 " h" 1
    GuiControl, Move, % hCBL3, % "x" A_GuiWidth - 20 " y" 13 " w" 1 " h" 1
    GuiControl, Move, % hCBR1, % "x" A_GuiWidth - 15 " y" 11 " w" 3 " h" 1
    GuiControl, Move, % hCBR2, % "x" A_GuiWidth - 14 " y" 12 " w" 3 " h" 1
    GuiControl, Move, % hCBR3, % "x" A_GuiWidth - 13 " y" 13 " w" 1 " h" 1
    GuiControl, Move, % hBar, % "x" 1 " y" A_GuiHeight - 23 " w" A_GuiWidth - 2 " h" 22
    GuiControl, Move, % hTitletext, % "x" 37 " y" 2 " w" A_GuiWidth - 96
    GuiControl, Move, % hBarText, % "x" 8 " y" A_GuiHeight - 19 " w" A_GuiWidth - 16
    WinSet, Redraw
}

}

 

class WinEvents
{
    static Table := {}


Register(hWnd, Class, Prefix="Gui")
{
    Gui, +LabelWinEvents.
    this.Table[hWnd] := {Class: Class, Prefix: Prefix}
}


Unregister(hWnd)
{
    this.Table.Delete(hWnd)
}


Dispatch(hWnd, Type)
{
    Info := this.Table[hWnd]
    return Info.Class[Info.Prefix . Type].Call(Info.Class)
}


Size()
{
    return WinEvents.Dispatch(this, "Size")
}

}


  • 리체 2015.10.09 10:11

    상당히 어려워지는 느낌이에요. ㅎㅎ;

    추천!

  • profile
    예지력1 2015.10.09 15:15
    오브젝트와 Class에 대한 글을 좀 작성해봐야겠어요
    대부분 개발자분들이 goto만 사용해서 소스가 좀 지저분한거같네요
  • 제발등업좀2 2015.10.09 17:48
    저같은 초보자를 위해서 최대한 쉽게 부탁드립니다..
    ㅠ.ㅠ 초보자입장에서 이런 글역시 감사할뿐이지만요 ㅎㅎ 추천!
  • profile
    와이로 2015.10.09 21:57
    함수 바인더라니 좋은거 알고 갑니다
    새로 추가된 기능에 관심도 가지고 그래야 하는데 이렇게 아기새처럼 입만 벌려 얻어먹네요
  • profile
    와이로 2015.10.10 13:02

    오늘 GUI 클래스 써보니 매우 유용하네요. 색상변경 쉽게 변수로 묶고 상속해서 내부 GUI 추가해서 쓰면 심플하면서도 개성있는 GUI를 만들 수 있을것 같아요.

     

    하지만 미적 감각이 제로인 저로서는... 내부 GUI 추가해도 투박해질것 같은 암울한 느낌이 드는군요 ㅋㅋㅋ

  • 매크로맨서 2016.04.16 16:11

    대박 이쁘네요!


List of Articles
분류 제목 글쓴이 최근변경 추천
정보 오랫만에 들러서 하나 투척하고 가요 ^^ 7 로뎀나무 2019.07.30 0/0
정보 앱아이콘 터치없이 adb로 앱 실행 시키는 방법 18 와이로 2021.01.23 3/0
정보 DynaScript - Child 프로세스로 코드 실행 13 예지력1 2019.07.16 3/0
정보 저번에 올려드린 홈페이지보다 더 유용한 사이트 5 침묵의고요 2018.02.07 2/0
정보 adb 관련 비활성화 이미지 서치 쉽게하기 6 운하파는 2016.07.02 1/0
정보 [Lib] Class MsgBox, 메시지박스 확장 4 예지력1 2015.11.27 2/0
정보 오토핫키 이미지 스위치... 6 파더 2015.11.27 0/0
정보 오토핫키를 간단히 쓰고싶지만 너무 어렵다고 느낄때 9 HyunsD 2018.02.07 3/0
정보 간단한 방법으로 길오아 오토핫키를 만들어보세요^^ 21 럭셔리형아 2018.02.07 4/0
정보 g라벨? v라벨? 설명좀해주세요 5 이리오리오 2016.10.25 0/0
정보 ㅋㅋㅋㅋ 베스트글 보려고 2랩찍으려다가 2랩 찍기전에... 6 sica 2018.03.03 0/0
정보 팝업 알림, CleanNotify 3 예지력1 2015.11.11 4/0
정보 MS오피스 스타일 GUI 프로토타입 6 예지력1 2016.04.16 4/0
정보 맥주소 얻기 12 와이로 2015.10.05 1/0
정보 Menu bar 근접하게 만들어봄 4 fnwj 2017.11.26 0/0
정보 [라이브러리] EasyINI 네이티브 ini 3 예지력1 2016.02.09 2/0
정보 네이버에서 현재시간 가져오기 6 와이로 2016.11.14 1/0
정보 제가 쓰는 비활성 드래그입니다.. 10 제발등업좀2 2021.01.23 0/0
정보 레이븐 블루스택용 소스 오픈 9탄 - 마지막 추천X 9 T7GG 2015.10.12 1/0
정보 레이븐 블루스택용 소스8탄 - 필요하신분쓰세요 추천X 4 T7GG 2016.11.14 1/0
Board Pagination Prev 1 23456 7 Next
/ 7

전체 최신 인기글

전체 주간 인기글