问题
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.
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.
回答1:
F1::
if( not GetKeyState("LButton" , "P") )
Click down
return
F1 Up::Click up
and same goes for right click
回答2:
F1::
if( not GetKeyState("LButton" , "P") )
Click down
return
F1 Up::Click up
This saved me 350 € for hardware parts !!! You are my new best friend !
来源:https://stackoverflow.com/questions/17048287/autohotkey-how-to-hold-a-mouse-button-while-a-key-is-pressed