在记事本中禁用拖放
Disable drag and drop in 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)
}
但是这个脚本引发了其他问题。值得注意的是,选择记事本window时,永远不会触发左键。
如何正确禁用记事本中的文件拖放功能(不丢失左键的正常行为)?
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)
}
我想禁用将任何内容放入记事本的功能。
我终于找到了禁用掉落的方法,就像这样:
*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)
}
但是这个脚本引发了其他问题。值得注意的是,选择记事本window时,永远不会触发左键。
如何正确禁用记事本中的文件拖放功能(不丢失左键的正常行为)?
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)
}