I can't for the Life of me figure out why this wont loop.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ahkjthunter4888
Posts: 11
Joined: 02 Jul 2021, 17:29

I can't for the Life of me figure out why this wont loop.

Post by ahkjthunter4888 » 26 Jul 2021, 14:01

I've tried many things from the "Autokey help" but I can't figure out for the life of me why this wont continuously loop. I'm sure it's something easy I'm overlooking. I just wanna be able to run the script and it loops over and over or run the script and then press an assigned hotkey and it with then continuously loop. Plz help and Thank you in advance for your knowledge and expertise.

Code: Select all


#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input


posX := [10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,20,45,73,105,133,167,195,228,258,288,320,350,382,415,445]
posY := [880,880,880,880,880,880,880,880,880,880,880,880,880,880,880,910,910,910,910,910,910,910,910,910,910,910,910,910,910,910,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,975,975,975,975,975,975,975,975,975,975,975,975,975,975,975,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1061,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065]
clr := 0xFFFFFF
char := ["1","2","3","4","5","6","7","8","9","0","t","g","k","y","u","!1","!2","!3","!4","!5","!6","!7","!8","!9","!0","!t","!g","!k","!y","!u","+1","+2","+3","+4","+5","+6","+7","+8","+9","+0","+t","+g","+k","+y","+u","^+1","^+2","^+3","^+4","^+5","6","^+7","^+8","^+9","^+j","^+t","^+g","^+k","^+y","^+u","^1","^2","^3","^4","^5","^6","^7","^8","9","^0","^t","^g","^k","^y","^u","^!1","^!2","^!3","^!4","^!5","^!6","^!7","^!8","^!9","^!0","^!t","^!g","^!k","^!y","^!u"]


`::
	Loop, % posX.MaxIndex()
	{
		PixelGetColor, color, posX[A_Index], posY[A_Index], Fast
		if (color = clr)
		{
			Send % char[A_Index]
			break
		}
	}
return

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

Re: I can't for the Life of me figure out why this wont loop.

Post by mikeyww » 26 Jul 2021, 14:24

What makes you believe that the routine does not loop? What is the value of your conditional statement (True or False)? You can add a line to the script to report that value to you.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: I can't for the Life of me figure out why this wont loop.

Post by boiler » 26 Jul 2021, 14:31

If you don’t want it to stop looping after the first time it finds a color and sends a character, remove the break line. That’s its purpose — to stop a loop from continuing to loop. If you want it to continue looping after going through the whole array (i.e., start from the beginning again), then you need to add another loop outside that loop:

Code: Select all

#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input


posX := [10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,10,45,73,105,133,167,195,228,258,288,320,350,382,415,445,20,45,73,105,133,167,195,228,258,288,320,350,382,415,445]
posY := [880,880,880,880,880,880,880,880,880,880,880,880,880,880,880,910,910,910,910,910,910,910,910,910,910,910,910,910,910,910,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,975,975,975,975,975,975,975,975,975,975,975,975,975,975,975,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1061,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065,1065]
clr := 0xFFFFFF
char := ["1","2","3","4","5","6","7","8","9","0","t","g","k","y","u","!1","!2","!3","!4","!5","!6","!7","!8","!9","!0","!t","!g","!k","!y","!u","+1","+2","+3","+4","+5","+6","+7","+8","+9","+0","+t","+g","+k","+y","+u","^+1","^+2","^+3","^+4","^+5","6","^+7","^+8","^+9","^+j","^+t","^+g","^+k","^+y","^+u","^1","^2","^3","^4","^5","^6","^7","^8","9","^0","^t","^g","^k","^y","^u","^!1","^!2","^!3","^!4","^!5","^!6","^!7","^!8","^!9","^!0","^!t","^!g","^!k","^!y","^!u"]


`::
	Loop
		Loop, % posX.MaxIndex()
		{
			PixelGetColor, color, posX[A_Index], posY[A_Index], Fast
			if (color = clr)
				Send % char[A_Index]
		}
return

Post Reply

Return to “Ask for Help (v1)”