Sending Input when Pixel detected in Region

Ask gaming related questions (AHK v1.1 and older)
User avatar
puuyo
Posts: 2
Joined: 23 Nov 2020, 05:52

Sending Input when Pixel detected in Region

23 Nov 2020, 05:59

hello all. I'm trying to write a script to send spacebar when it detects the blue pixel in the middle of this bar.
https://i.imgur.com/jELhyV1.gif

The issues is the ball is moving back and forth, and I want it to hit space only when the ball is in the roughly middle of the bar contained inside the 2 yellow lines.

Code: Select all

; COLOR DETECTION
; Goal: If Pixel is detected in square send space
; Issue: The object is moving back and forth

1::
Loop {
	
	PixelSearch, Px, Py, 902, 814, 928, 837, 0x11A7EA, 1, Fast
	
	if (ErrorLevel = 0) {
	
	Send {Space}
	}
	; else {
	; MsgBox, ERROR: Color not detected
	; }
}

2::exitapp
Hamborgar
Posts: 14
Joined: 28 Sep 2020, 09:57

Re: Sending Input when Pixel detected in Region

23 Nov 2020, 07:10

how about you make the pixelsearch only search the inside of the 2 yellow lines
User avatar
puuyo
Posts: 2
Joined: 23 Nov 2020, 05:52

Re: Sending Input when Pixel detected in Region

24 Nov 2020, 04:44

Figured out it apparently the ball starts from the same initial position so its actually simpler to do something like this

Code: Select all

1:: 

    Loop {
        ; relaunch minigame
        send {n} ; REPLACE WITH THE KEY BOUND TO OPEN MEDITATION
        ; wait until ball is position
        sleep 800
        
        ; break keyboard :)
        loop 5 {
        send {space}
        }
        
        ; close minigame
        send {n} ; REPLACE WITH THE KEY BOUND TO OPEN MEDITATION
        sleep 500
    }
    
2::exitapp 

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: vysmaty and 123 guests