Re: [AHK-] 仅在限定视窗内 用左键长按取代中键

楼主: bhbbbbb (影)   2020-11-25 17:22:09
※ 引述《ushenli (ushenli)》之铭言:
: 想要用鼠标左键长按 来取代中键
: 但只限定在 鼠标指向的视窗 是chrome的时候生效
: 不然的话 平常就没办法用左键拖曳档案了
: 东抄西改后 现在这样写
: 不知为什么 没办法限定只在chrome生效
: 想请问应该怎么改 感谢!
: #中键不好按中指都快抽筋
: MouseGetPos, , , id, ctrl
: if InStr(ctrl,"Chrome") {
: $lbutton::
: starttime := a_tickcount
: keywait, lbutton
: return
: lbutton up::
: if (a_tickcount - starttime >= 500)
: send, {Mbutton}
: if (a_tickcount - starttime <= 500)
: send, {lbutton}
: return
: }
我自己觉得你的想法是可以做到的,但实务上应该还是不太方便,例如反白之类的动作可能
也会出问题。
总之我用“先按著右键不放,再按下左键”的这个方法来取代中键
这样的话就算是在其他的视窗应该也不太会出事(但下面的范例我还是让他只在chrome中作用
b := false
#If Ms_On_win("ahk_exe chrome.exe")
~Lbutton::
if (getkeystate("RButton", "P"))
{
sendInput, {Mbutton}
b := true
return
}
return
$RButton Up::
if(!b)
SendInput, {RButton Up}
return
RButton::
b := false
return
#IF
Ms_on_win(win_title) {
MouseGetPos, x, y, ms_win
if(WinExist(win_title . " ahk_id " . ms_win)) {
;WinActivate, ahk_id %ms_win%
return ms_win
}
else
return false
}
希望有帮到你
作者: ushenli (ushenli)   2020-11-26 01:54:00
谢谢斯马克大费心 原以为简单到五六行就可以实现呢按住右+左=中也不错说 我也只是参考游戏才想用长按替代中我用了你提供的code 但似乎无法点击选单 比如https://imgur.com/PSHdVu0 https://imgur.com/zwydeIN

Links booklink

Contact Us: admin [ a t ] ucptt.com