Winning Putt (Golf Game)

Ask gaming related questions (AHK v1.1 and older)
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Winning Putt (Golf Game)

12 Mar 2017, 14:15

I tryed to make a script for this game.
The mechanic is to read the color of the pixel at x:959 y:868 (in 1920x1080). When this pixel changes his color to R:195 G:255 B:251or Hex C3FFFB (some cyan blue), then the slider is perfect at the sweetpoint and then it should instant press Spacebar. At best this happens only while holding down a button.
One problem is this game dont accept ahk inputs, you cant even CTRL+V to copypaste anything into the chat.

i tryed something like this but at first we need a solution the game dont accept inputs at all.

toggle :=0
o::
toggle := !toggle
if(toggle)
{
SetTimer, checkPixel, 100
} else {
SetTimer, checkPixel, off
}
return

checkPixel:
PixelGetColor, vcolor, 959, 868, RGB
send 3
if vcolor = 0xC3FFFB
sendInput {SPACE}
return
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

13 Mar 2017, 07:03

I still try to get anything into the game with very basic send letters on keystroke into the chat. The game just accept nothing from ahk so far.
I tryed around with different send types like sendinput, sendevent, sendplay and stuff (not sure if i do right) and also there is a Shot button wich can be clicked instead of pressing spacebar:

Image

and i tryed it with left mouseclicks on this position but this didnt work too. I tryed windowed, fullscreen, fullscreen window.

The game seems to be immune to any ahk interaction. Is there a way to simulate a real keystroke or mouseclick? Dont imagine how hard it couldt be to read out that color of that pixel wich should trigger the event.
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

13 Mar 2017, 08:33

I tryed this tool:
https://autohotkey.com/board/topic/9565 ... -tool-v41/

and it gets several clicks on the button but i dont know how to read out how its done.

When i rightclick my script and there is no start as admin option, how to start it as admin then?

0xFBFFC3 ist der Farbcode und pixel posi x:959 y:960
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

13 Mar 2017, 09:44

My next try:

Code: Select all

F8::

X2 := "959"
Y2 := "860"
Loop, {
   PixelGetColor, FarbeNeu2, %X2%, %Y2%
    if (FarbeNeu2 != 0xFBFFC3)
    {
     return
    }
SendRaw, {LButton}
}

return
doesnt work. Is there any relieable script working itself properly before doing the next step how to make the game interacting with ahk?
bluce
Posts: 70
Joined: 01 Feb 2017, 13:23

Re: Winning Putt (Golf Game)

13 Mar 2017, 10:02

If the game is not being run in a window, try doing that. It may be in the video settings.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Winning Putt (Golf Game)

14 Mar 2017, 10:17

If the game is not accepting input from AHK, the standard two pieces of advice apply:

1) Run the script as admin
2) Make sure keys are held for at least 50ms by placing SetKeyDelay, 0, 50 once, at the start of the script.
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

14 Mar 2017, 15:31

When the "send and click tool" (link above) gets clicks into the game, is it then sure possible for ahk general or does this tool work different?
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

27 Mar 2017, 12:40

Ok, the problem is not that the game accepts nothing because it accept mouseclicks and keyboardstrokes but the problem is while the game is the active window i cant trigger ahk.

I put the game in windowmode now, so i have 2-3cm desktop on the side and after click desktop i can trigger the shotbutton per

SendEvent {Click 888, 909, down}{click 888, 910, up}

So the first problem is solved. Next problem is now how to read out that pixel. I dont get it. The slider is very fast so there is not much time to detect the color. Is there anything else like brightness detection or any tolerance settings like a range of colors?

My actuall attempt is:

SetKeyDelay, 0, 50

Loop,
{
Sleep, 1000
PixelGetColor, color, 1015, 835
If color = 0xFBFFC3
{
SendEvent {Click 888, 909, down}{click 888, 910, up}
SendEvent {Click 888, 909, down}{click 888, 910, up}
}
Else
{
return
}
}
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

27 Mar 2017, 14:06

ok another idea. The groundcolor is always different depending on the ball situation. Sometimes you have a big green sweetpoint and sometimes nearly everything is red on bad ground.

So what about at first get this color and then react when it changes to anything else?

So:

any button press
get actual color save variable color1
then start the loop and read the color at the point and compare to color1

so we have a "is not question" based on color1

SetKeyDelay, 0, 50

o::

PixelGetColor, color1, 1015, 835

Loop,
{
PixelGetColor, color2, 1015, 835
If color2 != color1
{
SoundBeep, 750, 500
}
Else
{
sleep 1
}
}

I get color1 once and set it
then i get color2 at the same point as loop and compare it to color1

but when i start this it instant triggers without end, why? (i replaced my meanwhile working clickaction with a beep)

I actually try this not even ingame, just on the desktop and then move any random window around to change the color.
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

27 Mar 2017, 16:54

ok, i got something:

toggle := 0
F1::
toggle := !toggle
if(toggle)
{
SetTimer, pixelCheck, 1

} else {
SetTimer, pixelCheck, Off
}
return

pixelCheck:
PixelGetColor, color2, 957, 864, RGB
If (color2 = 0xC3FFFB)
{
MouseClick, left, 950, 950
SoundBeep, 500, 200
}
Else
{

}

return

F1 is to toggle on/off
he did once a slight push automatically and hit shot automatically several times but mostly he dont react at all. Overall its barely working but it needs finetuning. Any tipps? (the coordinates are back to fullscreen aka borderless window now)
playlessNamer
Posts: 14
Joined: 08 Apr 2016, 12:43

Re: Winning Putt (Golf Game)

31 Mar 2017, 11:16

Thw script triggers sometimes but its to slow. The delay is 1ms but it seems to not ask the pixelcolor often enough. Is there a faster way to search pixel? I just play around with "searchpixel" in a 2x2 area but i dont get it runnin. Is search pixel even faster than getpixelcolor? Are there other ways to detect the slider on the sweetpoint?
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Winning Putt (Golf Game)

31 Mar 2017, 13:14

The minimum granularity of a SetTimer is ~10ms.

So when you do SetTimer, pixelCheck, 1, you are actually getting no different than if you did SetTimer, pixelCheck, 10

For faster pixel detection, see GDI+, or my library that wraps it, CGDipSnapshot

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 39 guests