a cursor moving with colour detection script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
[m]
Posts: 21
Joined: 05 May 2020, 14:12

a cursor moving with colour detection script

22 Apr 2021, 19:41

So I had this idea from a game where you play as a ball, and you roll over a pillar which switches the colour of a pillar (The one that is under you). The pillars that are touching the edge (corner pillars don't change), change to the opposite colour (from red to green/green to red).

Say you move your mouse over a red area, you left click it, then the colour changes to green, the edge areas (so north, east, south and west of the cursor)
that were green before, are now red.
Below you can see an example (in emojis ¯\_(ツ)_/¯ ) so you see it better.

--- :mrgreen:............................. :oops:
:mrgreen: :oops: :mrgreen:..................... :oops: :mrgreen: :oops:
--- :mrgreen:............................. :oops:
Before...........................After

I was wondering if that was possible with a script that does the same thing using your mouse when left clicking the red/green areas.
As always, help is indeed appreciated!
Last edited by [m] on 23 Apr 2021, 09:16, edited 1 time in total.
User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: a cursor moving with colour detection script

22 Apr 2021, 20:16

Code: Select all

dir := A_ScriptDir, c0 := dir "\red.png", c1 := dir "\green.png", colors := "11011"
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=12973, %c0%
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=12972, %c1%
Gui, Add, Picture, x40         vg1, %c1%
Gui, Add, Picture, x10         vg2, %c1%
Gui, Add, Picture, x40 yp gRed vg3, %c0%
Gui, Add, Picture, x70 yp      vg4, %c1%
Gui, Add, Picture, x40         vg5, %c1%
Gui, Show,, Pic
Return

Red:
on := !on
Loop, Parse, colors
{ pic := "c" on ^ A_LoopField
  GuiControl,, g%A_Index%, % %pic%
}
Return

GuiEscape:
GuiClose:
ExitApp
Outside a GUI, if you want to find the color under a click, you can create a hotkey for LButton, with a routine that includes MouseGetPos and PixelGetColor.
Attachments
red.png
red.png (123 Bytes) Viewed 182 times
green.png
green.png (123 Bytes) Viewed 182 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, ShatterCoder and 131 guests