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

查看:729
本文介绍了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?

我在这两个自动热键论坛上进行了一些研究(重定向到这里询问问题)并阅读了文档,但是我不是程序员,并且很难掌握循环.

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天全站免登陆