Need help please

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
akosipaul1
Posts: 1
Joined: 21 May 2024, 06:28

Need help please

21 May 2024, 06:38

Hi all,

I would like to kindly ask help regarding this code:

Code: Select all

5::

SendInput m
Sleep 20
SendInput m
Sleep 500


loop,
	{
		SendInput u
		Sleep 20
		SendInput l
		Sleep 20
		SendInput y
		Sleep 20
		
		
	}        <---- when 5 is pressed only the commands above will be inputted.


SetTimer, Loops, -1  <--- however these codes also gets inputted when I press 5, which I don't want it to do when I press 5.
$4::Loop = 4
$e::Loop = e
$s::Loop = s
$q::Loop = q
$r::Loop = r
$x::Loop = x
Loops:
Loop
{
	While, Loop = "x"
	{
		SendInput m
		Sleep 80
		SendInput m
		Sleep 80
			
	}
	While, Loop = "e"
	{
		SendInput m
		Sleep 20
		SendInput m
		Sleep 20
		SendInput u
		Sleep 20
		SendInput u
		Sleep 20
		SendInput l
		Sleep 20
		SendInput y
		Sleep 20
		
	}
	While, Loop = "4"
	{
		SendInput y
		Sleep 20
		SendInput l
		Sleep 20
			
	}
	While, Loop = "r"
	{
		SendInput u
		Sleep 20
		SendInput u
		Sleep 20
		SendInput l
		Sleep 20
		SendInput y
		Sleep 20
		SendInput u
		Sleep 20
	}
	
	While, Loop = "s"
	{
	break
	}
	While, Loop = "q"
	{
		SendInput l
		Sleep 30
			
	}
	
}

Return
What I would like to happen is that when I press 5 it will execute commands that are present above the "SetTimer, Loops, -1" but will still be able to "break" if I press the "s" button. I know this is kinda complicated but your help will be most greatly appreciated. :D

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod edit: Moved topic from AHK v2 help since this is v1 code.]
User avatar
mikeyww
Posts: 27261
Joined: 09 Sep 2014, 18:38

Re: Need help please

21 May 2024, 07:28

Welcome to this AutoHotkey forum!

You are mistaken. Code following an infinite loop (within the same thread) does not execute because the loop is infinite. I would shorten your script, re-test, and then be more specific about what your script does, and what it should do, step by step. Include an example if possible.

The subject of your post should reflect the topic of your problem, not how you feel or whether you need help. See the forum board for examples.

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.

Hotkey subroutines typically end with a Return command. Without it and without any other control flow, the script will proceed to the next statement.

Who wrote the script that you posted?

A demonstration is below. Before you run the script, you can try to predict when the MsgBox will be displayed.

Code: Select all

#Requires AutoHotkey v1.1.33.11

5::
Send m
Loop {
 Send u
 Sleep 90
}
SoundBeep 1500
MsgBox
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 210 guests