Holding down button causing a function
Holding down button causing a function
Is it possible to code a way where when you hold down the left click button an action actively repeats however as soon as left click is let go it stops? Any help is appreciated.
Re: Holding down button causing a function
Code: Select all
LButton::
While GetKeyState("LButton", "P") {
Send x
Sleep, 20
}
Return
Re: Holding down button causing a function
How would I also make this script only work in a certain application? also thanks for the help.
Re: Holding down button causing a function
Please can you write a demonstration as this doesn't seem to be working, this is my code:
[Mod edit: [code][/code] tags added.]
Code: Select all
#IfWinActive ahk_class Notepad
return
LButton::
While GetKeyState("LButton", "P") {
mouseMove, 0, 100, 10, R
Sleep, 20
}
Return
Re: Holding down button causing a function
Code: Select all
notepad = ahk_class Notepad
#If WinExist(notepad) && mouseOver(notepad)
LButton::
If !WinActive(notepad)
WinActivate
Loop {
MouseMove, 0, 100, 10, R
Sleep, 20
} Until !GetKeyState("LButton", "P")
Return
#If
mouseOver(winTitle) {
MouseGetPos,,, hWnd
Return WinExist(winTitle " ahk_id" hWnd)
}