O
O
OstriySous2020-11-29 23:35:18
autohotkey
OstriySous, 2020-11-29 23:35:18

Why doesn't the script work in AHK?

I wrote a simple script that clamps the spacebar for 6 seconds in 55 minutes, I run it - it doesn’t work, tell me why?

Home::
~F3:: Suspend, Toggle
Loop
{
if(A_Min = 55)
{
Send "{Space down}"  ; Press down the up-arrow key.
Sleep 6000  ; Keep it down for one second.
Send "{Space up}"  ; Release the up-arrow key.
}
}
Return

End::
ExitApp
Return

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wisgest, 2020-11-30
@OstriySous

The quotation marks are Sendnot needed in or they need to be preceded by %. Also read Repeating or Holding Down a Key .
In the existing one, it is Loopdesirable to place a small one Sleepto reduce the load on the processor.
It is not clear why they are needed Returnafter the eternal loop and after ExitApp.
Also, it will not reach the main code, since, on the one hand, it is not in the auto-execution section (before all hotkeys), and on the other hand, it cannot be called by hotkey either, since there is an implicit before it Return, since the entry
~F3:: Suspend, Toggle
is abbreviated form

~F3::
 Suspend, Toggle
Return

A
a1987zz, 2020-12-05
@a1987zz

So maybe?
~F3::
Suspend, Toggle
Loop {
Sleep 1000 ; Keep it down for six seconds.
if (A_Min = 10) {
Send {Space down} ; Press down the key.
Sleep 6000 ; Keep it down for six seconds.
Send {Space up} ; Release the key.
}
}
return
End::
ExitApp
return

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question