Dont work, please help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Giorgio
Posts: 1
Joined: 02 Dec 2024, 10:06

Dont work, please help

Post by Giorgio » 02 Dec 2024, 10:14

Please help, my idea is to start script by press ctrl+5, then sprict should press and hold e for 5 sec, then releas e and wait 10 sec. they repeat script again untill stop by pressing ctrl+6
(script just press e and hold it)

Code: Select all

^5::
Loop

Send, {e down}
Sleep, 5000
Send, {e up}
Sleep, 10000
Return

^6::
  ExitApp
Return
Last edited by Ragnar on 02 Dec 2024, 10:24, edited 1 time in total.
Reason: code tags

cevvalkoala
Posts: 20
Joined: 05 Apr 2024, 03:41

Re: Dont work, please help

Post by cevvalkoala » 02 Dec 2024, 10:37

{* down} and {* up} work only with alt, ctrl et al., not with ordinary characters.

User avatar
mikeyww
Posts: 29718
Joined: 09 Sep 2014, 18:38

Re: Dont work, please help

Post by mikeyww » 02 Dec 2024, 11:00

Welcome to this AutoHotkey forum!

{... down} and {... up} can be used with any key. This is quickly demonstrated.

Code: Select all

#Requires AutoHotkey 1
Send {e down}
Sleep 500
Send {e up}
SoundBeep 1500
You can learn about code blocks: code blocks

Example
The loop statement is usually followed by a block, which is a collection of statements that form the body of the loop. However, a loop with only a single statement does not require a block (an "if" and its "else" count as a single statement for this purpose).
Source: Loop - Syntax & Usage | AutoHotkey v1
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.

cevvalkoala
Posts: 20
Joined: 05 Apr 2024, 03:41

Re: Dont work, please help

Post by cevvalkoala » 02 Dec 2024, 11:59

{... down} and {... up} can be used with any key.
Mikey, when the topic is AHK, I am inclined to trust you more than my eyes.
Still, when I run that script, I don't get an "eeeeeeeeeeeeeeeeeeeeeeeeee", but just a single e.
I must be doing (or expecting) something wrong.

RussF
Posts: 1484
Joined: 05 Aug 2021, 06:36

Re: Dont work, please help

Post by RussF » 02 Dec 2024, 12:35

cevvalkoala wrote: I don't get an "eeeeeeeeeeeeeeeeeeeeeeeeee", but just a single e.
You are correct, but that is not specifically what the OP originally asked for. Please see Repeating or Holding Down a Key.

Russ

ShatterCoder
Posts: 170
Joined: 06 Oct 2016, 15:57

Re: Dont work, please help

Post by ShatterCoder » 02 Dec 2024, 13:58

Giorgio wrote:
02 Dec 2024, 10:14
Please help, my idea is to start script by press ctrl+5, then sprict should press and hold e for 5 sec, then releas e and wait 10 sec. they repeat script again untill stop by pressing ctrl+6
(script just press e and hold it)
it appears that you are missing your brackets for the loop, so the code you posted will only run the first line after the loop endlessly so in essence you are just pressing e down and never releasing it.

Code: Select all

^5::
Loop
{ ;Note: brackets are needed here otherwise the loop will do nothing but send the first line over and over
Send, {e down}
Sleep, 5000
Send, {e up}
Sleep, 10000
} ;closing bracket
Return

^6::
  ExitApp
Return

Post Reply

Return to “Ask for Help (v1)”