Delta Pythagorean wrote:Code: Select all
~$LButton::
SetBatchLines, -1
SetKeyDelay, -1, -1
While (GetKeyState("LButton", "P")) && (!GetKeyState("Ctrl", "P")) {
SendInput, {LButton}
Sleep 50 ; milliseconds
}
Return
First question is done.
1) SetBatchLines -1 is very risky, and should be avoided. It also brings nothing useful to the script.
2) SetKeyDelay is pointless as you use SendInput, which is unaffected by SetKeyDelay
3) Putting both of these lines inside the hotkey is pointless and wasteful of CPU
4) Doing a while GetKeyState loop inside a hotkey is very bad practice, and only works with one hotkey, see
here.
Code: Select all
A::
SendInput, a
SendInput, {a Down}
KeyWait, p, D
SendInput, {a Up}
Return
Second it done.
If you are sending the same key as is used to trigger a hotkey, prefix with $. If you added a hotkey for d:: that does
Send {a}, then this would cause an infinite loop.
Plus, again, doing a KeyWait inside a hotkey is very bad practise, as previously mentioned in (3) above.
1) Yet another wait in hotkey no-no
2)
a and
P are variable names (Because no quotes), and neither variable is set, so you are passing no parameters to GetKeyState
3) This is incredibly wasteful of CPU and likely to cause 5-10% CPU usage, as you have no sleep in the loop.