매크로

질문
2019.02.22 18:06

이 소스 내용이 뭔가요?

조회 수 2488 추천 0 댓글 0

인터넷에서 클래스DD관련해서 찾다가 뭔가 대단해보이는 소스를 찾았는데

이거 그냥 DD호출하는 소스가 맞나요?

이거 글만 길게 썼다뿐이지, include, class_dd.ahk 이거랑 똑같은거죠?


class DD extends DD_Helper
{
        ; Simulate mouse button press
        ; param:   1 = LButton Down,    2 = LButton Up
        ;          4 = RButton Down,    8 = RButton Up
        ;         16 = MButton Down,   32 = MButton Up
        ;         64 = Button 4 Down, 128 = Button 4 Up
        ;        256 = Button 5 Down, 512 = Button 5 Up
        btn(param) {
                return DllCall(this.dllFile "\DD_btn", "int", param)
        }
    
        ; Simulate mouse move
        mov(x, y) {
                return DllCall(this.dllFile "\DD_mov", "int", x, "int", y)
        }
    
        ; Simulate mouse move (relatively)
        movR(dx, dy) {
                return DllCall(this.dllFile "\DD_movR", "int", dx, "int", dy)
        }
    
        ; Simulate mouse wheel
        ; param: 1=upward 2=downward
        whl(param) {
                return DllCall(this.dllFile "\DD_whl", "int", param)
        }
    
        ; Simulate keyboard
        ; param1: DD code
        ; param2: 1=Down 2=Up
        key(param1, param2) {
                return DllCall(this.dllFile "\DD_key", "int", param1, "int", param2)
        }
    
        ; VKCode to DD code
        todc(VKCode) {
                return DllCall(this.dllFile "\DD_todc", "int", VKCode)
        }
    
        ; Send string
        str(string) {
                return DllCall(this.dllFile "\DD_str", "astr", string)
        }
    
        ; Get hwnd of active window
        GetActiveWindow() {
                ; return DllCall(this.dllFile "\DD_GetActiveWindow", "ptr") ; seems not working
                return WinExist("A")
        }
    
        MouseMove(hwnd, x, y) {
                return DllCall(this.dllFile "\DD_MouseMove", "ptr", hwnd, "int", x, "int", y)
        }
    
        ; The picture is saved to "C:\DD Snap\" folder
        SnapPic(hwnd, x, y, w, h) {
                return DllCall(this.dllFile "\DD_SnapPic", "ptr", hwnd, "int", x, "int", y, "int", w, "int", h)
        }
    
        PickColor(hwnd, x, y, mode=2) {
                return DllCall(this.dllFile "\DD_PickColor", "ptr", hwnd, "int", x, "int", y, "int", mode)
        }
}

class DD_Helper
{
        static _ := DD_Helper.InitClass()
    
        InitClass() {
                if !A_IsAdmin {
                        Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
                        ExitApp
                }
                this.LoadDll()
        }
    
        LoadDll() {
                if A_Is64bitOS {
                        dllFile := (A_PtrSize=8) ? "DD\64\ddx64.64.dll" : "DD\64\ddx64.32.dll"
                } else {
                        dllFile := "DD\32\ddx32.dll"
                }
        
                if !this.hModule := DllCall("LoadLibrary", "Str", dllFile, "Ptr") {
                        if !FileExist(dllFile) {
                                throw, dllFile " not found."
                        }
                        throw, "LoadLibrary failed. DllFile is " dllFile
                }
                this.dllFile := dllFile
        }
    
        UnloadDll() {
                DllCall("FreeLibrary", "Ptr", this.hModule)
        }
        
        ; Example: _btn("RButtonDown")
        _btn(sNick, x:="", y:="") {
                static oNick := { LButtonDown: 1, LButtonUp: 2
                                , RButtonDown: 4, RButtonUp: 8
                                , MButtonDown: 16, MButtonUp: 32
                                , 4ButtonDown: 64, 4ButtonUp: 128
                                , 5ButtonDown: 256, 5ButtonUp: 512 }
                if !( n := oNick[sNick] ) {
                        throw, sNick " is not a valid nick."
                }
                if (x != "") {
                        this.mov(x, y)
                }
                this.btn(n)
        }
    
        ; Example: _btn_press("RButton")
        _btn_press(sNick, x:="", y:="", nCount:=1) {
                static oNick := { LButton: {Down: 1, Up: 2}
                                , RButton: {Down: 4, Up: 8}
                                , MButton: {Down: 16, Up: 32}
                                , 4Button: {Down: 64, Up: 128}
                                , 5Button: {Down: 256, Up: 512} }
                if !( o := oNick[sNick] ) {
                        throw, sNick " is not a valid nick."
                }
                if (x != "") {
                        this.mov(x, y)
                }
                Loop, % nCount {
                        this.btn( o.Down )
                        this.btn( o.Up )
                        Sleep, 5
                }
        }
    
        ; Example: _key("F11", "Down")
        ;          _key("F11", "Up")
        _key(sKey, sflag) {
                ddCode := this.todc( GetKeyVK(sKey) )
                this.key(ddCode, (sflag="Up") ? 2 : 1 )
        }
    
        ; Example: _key_press("F11")
        ;          _key_press("Ctrl", "A")
        _key_press(sKey*) {
                arr_ddCode := []
        
                for i, k in sKey {
                        arr_ddCode[i] := this.todc( GetKeyVK(k) )
                        this.key(arr_ddCode[i], 1) ; Down
                }
                for i, ddCode in arr_ddCode {
                        this.key(ddCode, 2) ; Up
                }
        }
    
        _key_pressEx(sKey, nCount := 1) {
                ddCode := this.todc( GetKeyVK(sKey) )
        
                Loop, % nCount {
                        this.key(ddCode, 1) ; Down
                        this.key(ddCode, 2) ; Up
                }
        }
    
        ; Example: _whl("down")
        ;          _whl("up")
        _whl(sParam) {
                this.whl( (sParam="Up") ? 1 : 2 )
        }
}



List of Articles
분류 제목 글쓴이 최근변경 추천
질문 gui창이 다른창을 눌러도 작업표시줄 안나타나게 할수... 초핫 2023.09.22 0/0
질문 오토핫키 매크로만드는법 강의자료 추천좀요 1 mnbmnb 2023.08.24 1/0
질문 메이플 거탐 까만부엉이 2023.08.13 0/0
질문 하드웨어 키입력 매크로사용할때 문제 2 응애제니 2023.10.18 0/0
자유 API 슬쩍 신공으로 디스코드를 드라이브처럼 써버리기 1 아스팔트맨 2023.10.22 0/0
질문 도저히 해결이안되서 질문드려요 2 어피치 2023.12.14 0/0
자유 오랜만에 오는데 자료가 많이 사라졌네요. 4 무쌍류 2023.10.18 0/0
질문 아스팔트맨 형님의 고견을 듣고싶습니다.. 2 바벌퀴레 2023.07.25 0/0
질문 이미지서치 예시 4 초보다초보 2023.11.04 0/0
자유 PostMessage 비활성 키입력 wparam, lparam 없이 하는 ... 아스팔트맨 2023.07.14 1/0
자유 심심해서 만든 업&다운 숫자게임 아스팔트맨 2023.07.14 0/0
질문 구 리니지 2.0 매크로 유료 제작가능 문의 태대호 2023.06.05 0/0
질문 배열 질문드립니다 3 광대승천 2023.05.26 0/0
질문 저장된 변수에 대해서 질문있습니다. 1 광대승천 2023.05.23 0/0
질문 형님들 왕초보 블루스택 adb에 연결하기 좀 도와주십시오. cis105 2023.05.08 0/0
질문 오토핫키 이미지맥스처럼 사용가능한가요? 1 호오오잇 2023.05.04 0/0
질문 오토핫키 반복하는 스크립트 줄이는 방법을 알고 싶습... 2 코난123 2023.04.30 0/0
질문 scrcpy 미러링 원래 비활성 안먹히나요? 3 리엔니케니스타 2023.07.17 0/0
질문 hid스틱 오토핫키 질문 저런곤란 2023.04.26 0/0
질문 텔레그램 이미지 보내는 방법아시는분.... 빨리올리져 2023.04.26 0/0
Board Pagination Prev 1 2345678910 ... 209 Next
/ 209

전체 최신 인기글

전체 주간 인기글