Отключить перетаскивание в блокноте - PullRequest
0 голосов
/ 13 ноября 2018

Я бы хотел отключить возможность бросать что-либо в Блокнот.

Наконец-то я нашел способ отключить сброс, например:

*lbutton::
send,{lbutton down}
keywait,lbutton,u 
if mouseIsOver("ahk_exe notepad.exe")
{
return
}
else
{
send,{lbutton up}
}
return

mouseIsOver(a){
mousegetpos,,,b
return winexist(a . " ahk_id " . b)
}

Но этот скрипт поднимает другие вопросы. Примечательно, что при выборе окна блокнота левая кнопка вверх никогда не срабатывает.

Как правильно отключить сброс файлов в блокноте (без потери нормального поведения левой кнопки)?

1 Ответ

0 голосов
/ 13 ноября 2018
 Critical  ; makes this thread uninterruptible

 #If !MouseIsOver("ahk_exe notepad.exe") ; "!" means "NOT"

    ~*LButton:: ; The tilde prefix (~) prevents AHK from blocking the  key-down/up events
    ~*RButton::
        ToolTip
        KeyWait, %A_ThisHotkey%, T0.3 ; wait 0,3 sec for the Button to be released
        if (ErrorLevel)               ; if KeyWait timed out (Button is still pressed down after 0,3 sec)
        {
            dropping := false ; assign the Boolean value "false" or "0" to this variable
            SetTimer, Stop_dropping, 10
                return
        }
        KeyWait, %A_ThisHotkey%
    return

#If

~*LButton Up::
~*RButton Up::
        dropping := true
        ToolTip
        SetTimer, Stop_dropping, off
return


Stop_dropping: 
    If (MouseIsOver("ahk_exe notepad.exe") &&  !dropping)   ; "&&" means "AND"
    {
        Send, {Esc} ; cancel dropping
        ToolTip No dropping
    }
return

mouseIsOver(a){
    mousegetpos,,,b
    return winexist(a . " ahk_id " . b)
}
...