禁用记事本中的拖放功能

时间:2018-11-13 11:33:35

标签: autohotkey notepad

我想禁用将任何东西放入记事本的功能。

我终于找到了一种禁用丢弃的方法,就像这样:

*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 :(得分:0)

 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)
}