duplicateMouse.ahk autohotkey 용 마우스 움직임 복제

new
F8로 동작 on/off 설정.
ESC로 종료









#Requires AutoHotkey v2.0
#SingleInstance Force

CoordMode "Mouse", "Screen"
SetMouseDelay -1

; =========================
; 설정
; =========================
offsetX := 560
offsetY := 0

enabled := true

startX := 0
startY := 0

; =========================
; F8 : ON/OFF 토글
; =========================
F8::{
    global enabled

    enabled := !enabled

    if enabled
        TrayTip "Macro", "ON"
    else
        TrayTip "Macro", "OFF"
}

; =========================
; 마우스 누름
; =========================
~LButton::{
    global startX, startY, enabled

    if !enabled
        return

    MouseGetPos &startX, &startY
}

; =========================
; 마우스 뗌
; =========================
~LButton Up::{
    global startX, startY
    global offsetX, offsetY
    global enabled

    if !enabled
        return

    MouseGetPos &endX, &endY

    ; 이동 거리
    dx := Abs(endX - startX)
    dy := Abs(endY - startY)

    ; 현재 위치 저장
    MouseGetPos &originalX, &originalY

    ; 복제 좌표
    cloneStartX := startX + offsetX
    cloneStartY := startY + offsetY

    cloneEndX := endX + offsetX
    cloneEndY := endY + offsetY

    ; =========================
    ; 클릭 처리
    ; =========================
    if (dx < 5 && dy < 5)
    {
        DllCall("SetCursorPos", "int", cloneStartX, "int", cloneStartY)

        Sleep 10

        SendLevel 0
        Click
        SendLevel 1
    }
    ; =========================
    ; 드래그 처리
    ; =========================
    else
    {
        DllCall("SetCursorPos", "int", cloneStartX, "int", cloneStartY)

        Sleep 10

        SendLevel 0
        SendEvent "{LButton Down}"
        SendLevel 1

        Sleep 10

        MouseMove cloneEndX, cloneEndY, 0

        Sleep 10

        SendLevel 0
        SendEvent "{LButton Up}"
        SendLevel 1
    }

    Sleep 10

    ; 원래 위치 복귀
    DllCall("SetCursorPos", "int", originalX, "int", originalY)
}

; =========================
; ESC 종료
; =========================
Esc::ExitApp
댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
목록형 📅 달력형