Help with: while x is true do, and press z at set timer Topic is solved

Ask gaming related questions (AHK v1.1 and older)
BlazerSirus
Posts: 3
Joined: 16 Apr 2021, 20:14

Help with: while x is true do, and press z at set timer

Post by BlazerSirus » 16 Apr 2021, 20:27

Hello everyone, can anyone help me?

Im trying to do a script that:
1) press L every 3 seconds (because in the game you have to press it to Target the enemy)
2) Search the enemy bar for the pixelcolor that equals red (which means he still has HP) and hit E while is still red

Basically, target the enemy every 3 seconds, and while he is alive, hit him. So when he is dead, i dont keep hitting the air. The enemy respawn every 30 seconds, but i have no way to predict how long will take for him to die, since is a multiple player raid.

It work, but once E start pressing it wont ever stop, even when the enemy is dead, and wont even press L again.

Here is my code, if anyone can help me:

Code: Select all

#SingleInstace Force
keydelay = 100
weapondelay = 550
;x1,y1 = 1360,74 x2,y2 = 1090,105. color from hp: b92929

loopL:
{
	Send {L down}
	Sleep, % keydelay
	Send {L up}
	Sleep, % keydelay
}

-::

SetTimer, loopL, 3000

	PixelSearch, 1360, 74, 1090, 105, 0xb92929, 10, RGB
	while (Errorlevel = 0)
		Loop, {
		Send {E down}
		Sleep, % keydelay
		Send {E up}
		Sleep, % weapondelay
}

saph
Posts: 68
Joined: 25 May 2020, 12:09

Re: Help with: while x is true do, and press z at set timer  Topic is solved

Post by saph » 16 Apr 2021, 20:44

You could try an if then else loop.

Code: Select all

Loop {
		Result1 := [SOME COMPARISSION]
		if (Result1) {
			Click, -500, 1000  ;if true, click here.

			} else {
            Click, -170, 1000  ;if not true, click here.
 	        }
BlazerSirus
Posts: 3
Joined: 16 Apr 2021, 20:14

Re: Help with: while x is true do, and press z at set timer

Post by BlazerSirus » 16 Apr 2021, 21:18

Worked! Did:

Code: Select all

-::
Loop,
{

	Send {L down}
	Sleep, % keydelay
	Send {L up}
	
	PixelSearch, x1,y1,x2,y2, colorid, 10, RGB
	if (ErrorLevel = 0)
		{
		Send {E down}
		Sleep, %  keydelay
		Send {E up}
		Sleep, % weapondelay
		}
		
}


Post Reply

Return to “Gaming Help (v1)”