Can you help me transfer code to AHK? Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Guest

Can you help me transfer code to AHK?

06 Dec 2017, 10:16

Hi, guys. I want to transfer to AHK. Can you please help me with this part of code?

It waits till a place at 73, 47 changes the color to 14671839

Code: Select all

Func Wait()
MouseMove(73, 47, 0)
Do
Sleep (20)
$var = PixelGetColor( 73, 47 )
Until $var = 14671839 or $var = 12895428
EndFunc
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Can you help me transfer code to AHK?

06 Dec 2017, 11:35

There's a function like this made by MasterFocus you can find at https://github.com/MasterFocus/AutoHotk ... PixelColor
Guest

Re: Can you help me transfer code to AHK?

06 Dec 2017, 20:32

My code has nothing to do with gaming. I have never used it for gaming.
TygerByte wrote:There's a function like this made by MasterFocus you can find at https://github.com/MasterFocus/AutoHotk ... PixelColor
Thank you. Sorry, I'm very bad at programming, what do I do with it? Is there a version of my lines in AHK? I can't find an analog for Func and Do.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can you help me transfer code to AHK?  Topic is solved

07 Dec 2017, 00:12

- You probably want something like this:

Code: Select all

Wait()
{
	CoordMode, Pixel, Screen
	CoordMode, Mouse, Screen
	;MouseMove, 73, 47, 0 ;probably unnecessary
	Loop
	{
		Sleep, 20
		PixelGetColor, vCol, 73, 47 ;BGR
		;PixelGetColor, vCol, 73, 47, RGB ;RGB
	} Until (vCol = 14671839) || (vCol = 12895428)
}

;alternatively
Wait2()
{
	CoordMode, Pixel, Screen
	CoordMode, Mouse, Screen
	;MouseMove, 73, 47, 0 ;probably unnecessary
	Loop
	{
		Sleep, 20
		PixelGetColor, vCol, 73, 47 ;BGR
		;PixelGetColor, vCol, 73, 47, RGB ;RGB
		if (vCol = 14671839) || (vCol = 12895428)
			break
	}
}
- I presume your code is AutoIt code. AutoIt's help doesn't say whether PixelGetColor is BGR or RGB, I'm guessing BGR.
- Functions and loops:

Code: Select all

MsgBox, % Func("c", "d")
Func(a, b)
{
	MsgBox, % a " " b
	MsgBox, % "hello world"
	return 1
}

Loop, 5
{
	if (A_Index = 4)
		break
	MsgBox, % A_Index
}
- AutoHotkey v2 uses functions for everything, so it may be easier to convert from AutoIt to AutoHotkey v2.
- Or, you can use function versions of commands in AHK v1 via this library:
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=29689
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 45 guests