Combine 2 different scripts into one?

Ask gaming related questions (AHK v1.1 and older)
User avatar
Dumitas
Posts: 167
Joined: 14 Dec 2017, 21:32

Combine 2 different scripts into one?

17 Dec 2017, 20:46

Hi! Im working on two scripts for a game, here a sample of both :

Movement Script:

Code: Select all

~Joy10::pause
~*$Joy9::
loop
{
send, {d down}
sleep 123
send, {d up}
sleep 123
send, {a down}
sleep 231
send, {a up}
sleep 123
}
return

Clicks Scripts using PixelGetColor

Code: Select all

~Joy10::pause
~*$Joy9::
Loop
{
	PixelGetColor, Pix1, 123, 123
		if Pix1= COLOR1
		{ 
			sleep 1000
			PixelGetColor, Pix2, 456, 456
			if Pix2= COLOR2
			{
				MouseClick, left, 321, 321
			}
		else if Pix2 != COLOR2
			{ ;
				MouseClick, left, 345, 345
			}
	else
		{
		Sleep, 1234
		}
	}
}
return

They work on two .ahk files and work perfect even with the same hotkey (they don't need each other to work), but don't know how to make them work in one file (with the same hotkey aslo)


Thank you in advance.
Image
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Combine 2 different scripts into one?

18 Dec 2017, 05:40

Hallo,
untested, try:

Code: Select all

Strings = {d down},{d up},{a down},{a up} ;Strings comma separated
StringSplit, Strings, Strings,`,
Return ;End of Auto-execute Section

~Joy10::pause
~*$Joy9::
SetTimer, SendStrings, 123
Loop
{
	PixelGetColor, Pix1, 123, 123
		if Pix1= COLOR1
		{ 
			sleep 1000
			PixelGetColor, Pix2, 456, 456
			if Pix2= COLOR2
			{
				MouseClick, left, 321, 321
			}
		else if Pix2 != COLOR2
			{ ;
				MouseClick, left, 345, 345
			}
	else
		{
		Sleep, 1234
		}
	}
}
Return
SendStrings:
	Counter := Mod(0 Counter,Strings0)+1
	Send % Strings%Counter%
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 97 guests