Hold down key while mouse button is down

Post a reply


In an effort to prevent automatic submissions, we require that you type the text displayed into the field underneath.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Hold down key while mouse button is down

Re: Hold down key while mouse button is down

Post by pocpoc » 21 Apr 2017, 06:22

I suspected that the intrinsic behaviour was different, thank you!

Interestingly enough however, it doesn't behave the same with Volume_Up and with Volume_Down.
With Volume_Up the volume steadily increases but with Volume_Down it starts normally then suddenly accelerates.

EDIT: This has actually nothing to do with autohotkey but is the behaviour of the Volume_Down key on my computer. After more than 6 fast presses, the volume step changes from 2 to about 10. Funny that this only happens with Volume_Down though. I guess it's better to be able to quickly turn the volume down than up :)

Re: Hold down key while mouse button is down

Post by Nextron » 21 Apr 2017, 06:07

Keyboard keys have a native key repeat, so holding a button down and releasing it results in the events: down-down-down-down-up; repeatedly triggering the hotkey. Mouse button don't have that, so you need to mimic it:

Code: [Select all]GeSHi © Codebox Plus

^LButton::
Loop {
Send {Volume_Up}
Sleep 200
}Until !GetKeyState("LButton","P")
Return

Hold down key while mouse button is down

Post by pocpoc » 21 Apr 2017, 05:12

I want a key to be pressed while I hold ctrl+mouseClick, but it only presses it once.

Code: [Select all]GeSHi © Codebox Plus

^LButton::Send {Volume_Up} ; this sends Volume_Up once when I hold the mouse


However, when I do the same with a keyboard key, it works fine.

Code: [Select all]GeSHi © Codebox Plus

^Up::Send {Volume_Up} ; this sends Volume_Up once when I press the key then continuously (the normal behaviour for a direct keypress)


Thank you for your help,
pocpoc

Top