행위

Autoit 마우스 선택시 텍스트 복사

DB CAFE

thumb_up 추천메뉴 바로가기


HotKeySet("{ESC}", "_Mouse_Exit_App")

Global $i_Mouse_Is_Down = False
Global $i_Mouse_Primary = 0x01 ; 0x01 = left for primary, 0x02 = right

Global $a_hMouseMod_hTimer = _Mouse_StartWatch("_Mouse_GetHighlight_ToClipboard", 0, 10001, 1000)

While 1
    Sleep(100)
WEnd

Func _Mouse_GetHighlight_ToClipboard()
    If Not $i_Mouse_Is_Down Then
        Local $a_GetAsync = DllCall("User32.dll", "int", "GetAsyncKeyState", "int", $i_Mouse_Primary)
        
        If Not @error And BitAND($a_GetAsync[0], 0x8000) = 0x8000 Then
            $i_Mouse_Is_Down = True
            
            While Not @error And BitAND($a_GetAsync[0], 0x8000) = 0x8000
                Sleep(50)
                $a_GetAsync = DllCall("User32.dll", "int", "GetAsyncKeyState", "int", $i_Mouse_Primary)
            WEnd
            
            Send("^{Insert}")
            Sleep(100)
            
            $i_Mouse_Is_Down = False
        EndIf
    EndIf
    
    Return 1
EndFunc

Func _Mouse_StartWatch($sCallback_Func, $hWnd, $iEvent_ID, $iEvent_Time)
    Local $h_Mouse_Mod = DllCallbackRegister($sCallback_Func, "int", "")
    If @error Then Return SetError(@error, 1, 0)
    
    Local $h_Timer = DllCall("User32.dll", "int", "SetTimer", _
                        "hwnd", $hWnd, _
                        "int", $iEvent_ID, _
                        "int", $iEvent_Time, _
                        "ptr", DllCallbackGetPtr($h_Mouse_Mod))
    
    If @error Then Return SetError(@error, 2, 0)
    
    Local $aRet[2] = [$h_Mouse_Mod, $h_Timer[0]]
    
    Return $aRet
EndFunc

Func _Mouse_StopWatch(ByRef $h_Mouse_Mod, ByRef $h_Timer, $hWnd = 0)
    If $h_Mouse_Mod > 0 Then
        DllCallbackFree($h_Mouse_Mod)
        $h_Mouse_Mod = 0
    EndIf
    
    If $h_Timer > 0 Then
        DllCall("User32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $h_Timer)
        If @error Then Return SetError(@error, 0, 0)
        
        $h_Timer = 0
    EndIf
    
    Return 1
EndFunc

Func _Mouse_Exit_App()
    _Mouse_StopWatch($a_hMouseMod_hTimer[0], $a_hMouseMod_hTimer[1])
    
    Exit
EndFunc