Autohotkey 如何在按下键时按住鼠标按钮? [英] Autohotkey How to hold a mouse button while a key is pressed?

查看:56
本文介绍了Autohotkey 如何在按下键时按住鼠标按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:我如何编写自动热键脚本,以便当我按下 F1 时,它会按下鼠标按钮,只有在我松开键后才松开?

In short: How do I write an autohotkey script so that when I press, say, F1, it presses the mouse button down and only lets it go after I let go of the key?

我在两个 autohotkey 论坛(重定向到这里提问)都做了一些研究并通读了文档,但我不是程序员,很难掌握循环.

I did some research on both autohotkey forums (which redirect here for asking questions) and read through the documentation, but I'm no programer and have a difficult time grasping loops.

我尝试过 while 或 if(getkeystate("F1") 循环,但我一直出错,直到最后我完成了这个几乎可以工作的脚本.

I tried doing while or if(getkeystate("F1") loops but I kept getting it wrong until finally I've ended up with this script, which almost works.

F2::Click down right
F2 Up::Click up right
F1::Click down
F1 Up::Click up

当我说几乎时,我的意思是它没有按住鼠标按钮.相反,我得到的是鼠标点击速度非常快.对于游戏等大多数情况来说已经足够了,它基本上相当于按住鼠标按钮或拖动窗口,但是当我想突出显示一个长段落时,它不起作用.一两秒后,整个东西开始闪烁,或者选择重置,在中间选择等等.基本上,如果你一直非常快速地点击鼠标按钮,它通常会发生什么.

When I say almost, I mean it doesn't hold the mouse button down. What I get instead is the mouse clicking insanely fast. It's good enough for most situations like games, where it's basically the equivalent of holding the mouse button, or dragging windows, but when I want to highlight a long paragraph, it doesn't work. After a second or two the whole thing starts blinking or the selection resets, selects in the middle, etc. Basically, it does what would normally happen if you just kept clicking your mouse button really really fast.

这也是这个问题中发布的相同解决方案如何在按键时按住鼠标?

This is also the same solution as posted in this question How to Hold Down Mouse while Key is Pressed?

我最初在它下面发布了一个后续问题,但显然这是不允许的,它被删除了,所以我必须创建另一个同名的问题,因为我想要同样的东西.

I initially posted under it a follow-up question, but apparently this is not allowed and it got deleted so I have to create another question with the identical name because I want the same thing.

请帮助或阐明我做错了什么.

Please help or shed some light on what I'm doing wrong.

推荐答案

F1::
    if( not GetKeyState("LButton" , "P") )
        Click down
return

F1 Up::Click up

右键单击也是如此

这篇关于Autohotkey 如何在按下键时按住鼠标按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆