Finding a clicking colors on a 3D application

Ask gaming related questions
Nebula
Posts: 3
Joined: 20 Jan 2021, 10:16

Finding a clicking colors on a 3D application

Post by Nebula » 24 Jan 2021, 21:54

I'm new to coding and I was trying to figure out how to script a code that clicks on a certain color on the screen of a 3D application with a loop function in a certain amount of time. The color I need to click it #b21fb8 but I just can't seem to get it correctly because when I run any of my scripts my cursor looks straight at the sky.
Last edited by BoBo on 25 Jan 2021, 01:34, edited 1 time in total.
Reason: Moved to Gaming section.
User avatar
mikeyww
Posts: 5351
Joined: 09 Sep 2014, 18:38

Re: Finding a clicking colors on a 3D application

Post by mikeyww » 24 Jan 2021, 22:31

This searches the active window, row by row, starting at the top. It will find the first match.

Code: Select all

color := 0xB81FB2 ; Blue, green, red
WinGetPos,,, width, height, A
SetTimer, Check, 300
Check:
PixelSearch, x, y, 0, 0, %width%, %height%, %color%,, Fast
If !ErrorLevel {
 SoundBeep, 1500, 30
 MouseClick,, x, y
} Else SoundBeep, 1000, 30
Return

F4::
SoundBeep, 1000, 30
ExitApp
Nebula
Posts: 3
Joined: 20 Jan 2021, 10:16

Re: Finding a clicking colors on a 3D application

Post by Nebula » 24 Jan 2021, 23:07

mikeyww wrote:
24 Jan 2021, 22:31
This searches the active window, row by row, starting at the top. It will find the first match.

Code: Select all

color := 0xB81FB2 ; Blue, green, red
WinGetPos,,, width, height, A
SetTimer, Check, 300
Check:
PixelSearch, x, y, 0, 0, %width%, %height%, %color%,, Fast
If !ErrorLevel {
 SoundBeep, 1500, 30
 MouseClick,, x, y
} Else SoundBeep, 1000, 30
Return

F4::
SoundBeep, 1000, 30
ExitApp
I tried to use your script however the problem still occurred Here is a video of what is happening. https://imgur.com/a/byQNFAc
User avatar
mikeyww
Posts: 5351
Joined: 09 Sep 2014, 18:38

Re: Finding a clicking colors on a 3D application

Post by mikeyww » 25 Jan 2021, 06:52

You probably need to decrease the timer interval quite a bit.

To test the approach, try a static image, and see if the routine can find the right color in it. You can also add a temporary MsgBox to confirm that the color was found.
Nebula
Posts: 3
Joined: 20 Jan 2021, 10:16

Re: Finding a clicking colors on a 3D application

Post by Nebula » 25 Jan 2021, 17:04

I've only been coding for a couple days so i'm not really sure on how to do all of that stuff. At the moment i'm trying to learn how to basics of cursor tracking works and having to do with fundamentals.
User avatar
mikeyww
Posts: 5351
Joined: 09 Sep 2014, 18:38

Re: Finding a clicking colors on a 3D application

Post by mikeyww » 25 Jan 2021, 17:20

You can run the following script.

Code: Select all

color := 0xB81FB2 ; Blue, green, red
F3::
WinGetPos,,, width, height, A
PixelSearch, x, y, 0, 0, %width%, %height%, %color%,, Fast
WinGetActiveTitle, this
MsgBox, 64, Result, Window: %this%`n`nx=%x%`ny=%y%
Return
Next, show your static image on the screen (e.g., a screenshot). Activate the window that is showing that image. Press F3. See if the color was found.
Post Reply

Return to “Gaming”