Page 1 of 1

Need a basic script and help

Posted: 09 May 2023, 03:43
by Galakrond
Hello, I need a script where I can predetermine the Pixels that will be pressed on the keys.

It can be like that, For example;



Pixels= 0xFFFFF0 , 0x593FFF , 0x92349 , 0x23494 ,

If win active RAYGOX

LOOP

PixelSearch, FoundX, FoundY, 200, 200, 200, 200,
if color=0xFFFFF0
sendinput 1
if color=0x593FFF
sendinput 2
if color=0x923495
sendinput 3
if color=0x234943
sendinput 4



There is 2 things will help me much, the stucture of this code. Speed of searching and pressing buttons.
Thanks for any help! ^^

Re: Need a basic script and help

Posted: 09 May 2023, 04:07
by boiler
We have again had to move your thread from the main section, which is for AHK v2 code. Please notice where this thread has been moved to and post in the appropriate section from now on.

Also, makes your subject titles more descriptive about what you need help with. Everyone who posts here needs help.

Re: Need a basic script and help

Posted: 09 May 2023, 04:11
by Galakrond
boiler wrote:
09 May 2023, 04:07
We have again had to move your thread from the main section, which is for AHK v2 code. Please notice where this thread has been moved to and post in the appropriate section from now on.

Also, makes your subject titles more descriptive about what you need help with. Everyone who posts here needs help.
Thank you, sorry for confusion.

Re: Need a basic script and help

Posted: 09 May 2023, 04:14
by boiler
Regarding your post, in a recent post, you tried to make a search rectangle when using PixelGetColor. Now your search rectangle is only one pixel, so you really should be using PixelGetColor in this case.

Re: Need a basic script and help

Posted: 09 May 2023, 04:37
by Galakrond
boiler wrote:
09 May 2023, 04:14
Regarding your post, in a recent post, you tried to make a search rectangle when using PixelGetColor. Now your search rectangle is only one pixel, so you really should be using PixelGetColor in this case.
Sorry for making confusion.
This part of the script is important for me.

''
If win active RAYGOX

LOOP

PixelSearch, FoundX, FoundY, 200, 200, 200, 200,
if color=0xFFFFF0
sendinput 1
''

I gave the coordinates as an example. Not real coordinates.

Can it trace inside a rectangle with PixelGetColor? (I guess no.) (if yes, great)

Because PixelSearch is running a bit slow. As I wrote in the example, I would like to specify the place where the monitoring will be performed once. The place to be traced is a maximum 20x20 rectangle. **The pixels are not at the same place in that rectangle.**

I'm having trouble making the code whole. Can you help me?

Re: Need a basic script and help

Posted: 09 May 2023, 04:45
by boiler
Galakrond wrote: Can it trace inside a rectangle with PixelGetColor? (I guess no.) (if yes, great)
No, PixelGetColor is for getting the color of a single pixel.

Galakrond wrote: Because PixelSearch is running a bit slow.
Did you specify Fast in the Mode parameter?

Re: Need a basic script and help

Posted: 09 May 2023, 04:51
by Galakrond
Sure its like this, but please ignore the coords.

Code: Select all

PixelSearch, FoundX, FoundY, 569, 555, 990, 672, 0x940000, 0, Fast RGB
Also with these structure, im editing all other colors coords again an again. :( (pain)

Re: Need a basic script and help

Posted: 09 May 2023, 06:35
by boiler
I guess you’re looking to do something like this:

Code: Select all

Colors := [0xFFFFF0, 0x593FFF, 0x92349, 0x23494]
for Num, Color in Colors
{
	PixelSearch,,, 569, 555, 990, 672, Color, 0, Fast RGB
	if !ErrorLevel
		Send, % Num
}

Re: Need a basic script and help

Posted: 09 May 2023, 06:45
by Galakrond
boiler wrote:
09 May 2023, 06:35
I guess you’re looking to do something like this:

Code: Select all

Colors := [0xFFFFF0, 0x593FFF, 0x92349, 0x23494]
for Num, Color in Colors
{
	PixelSearch,,, 569, 555, 990, 672, Color, 0, Fast RGB
	if !ErrorLevel
		Send, % Num
}
Yes,nearly.

Defining the coordinate. Done.
Defining colors. Done.
One last thing left, defining the keys to be pressed for the colors.
Like; press 1 for 0xFFFFF0 color. press 2 for 0x593FFF color. press 3 for 0x92349 color.
Also it would be awesome if its in loop

Re: Need a basic script and help

Posted: 09 May 2023, 06:58
by boiler
Galakrond wrote: One last thing left, defining the keys to be pressed for the colors.
Like; press 1 for 0xFFFFF0 color. press 2 for 0x593FFF color. press 3 for 0x92349 color.
Nope. Also done for those numbers (and 4 for the last color).

Galakrond wrote: Also it would be awesome if its in loop
Put the word loop on a line before the for… line.

Re: Need a basic script and help

Posted: 09 May 2023, 07:00
by Galakrond
boiler wrote:
09 May 2023, 06:58
Galakrond wrote: One last thing left, defining the keys to be pressed for the colors.
Like; press 1 for 0xFFFFF0 color. press 2 for 0x593FFF color. press 3 for 0x92349 color.
Nope. Also done for those numbers (and 4 for the last color).

Galakrond wrote: Also it would be awesome if its in loop
Put the word loop on a line before the for… line.
Thank you so much boiler, i will try it and inform you again. Much appriciated 🤙🏻

Re: Need a basic script and help

Posted: 09 May 2023, 15:02
by Galakrond
boiler wrote:
09 May 2023, 06:35
I guess you’re looking to do something like this:

Code: Select all

Colors := [0xFFFFF0, 0x593FFF, 0x92349, 0x23494]
for Num, Color in Colors
{
	PixelSearch,,, 569, 555, 990, 672, Color, 0, Fast RGB
	if !ErrorLevel
		Send, % Num
}
Hello boiler,

how can i set the keys not like 1 , 2 , 3 but with shift; +{1}, +{2}, +{3}?

Re: Need a basic script and help

Posted: 09 May 2023, 15:43
by boiler
The easiest way is like this since they happen to be 1, 2 3, 4:

Code: Select all

Colors := [0xFFFFF0, 0x593FFF, 0x92349, 0x23494]
for Num, Color in Colors
{
	PixelSearch,,, 569, 555, 990, 672, Color, 0, Fast RGB
	if !ErrorLevel
		Send, % "+" Num
}
The braces aren't needed for keys like 1, 2, 3.

If you wanted to more generally map a set of keys to them that don't happen to line up numerically, you could make an associative array, like this:

Code: Select all

Colors := {"+{F4}": 0xFFFFF0, "+{F5}": 0x593FFF, "^{Tab}": 0x92349, "+{Space}": 0x23494}
for Key, Color in Colors
{
	PixelSearch,,, 569, 555, 990, 672, Color, 0, Fast RGB
	if !ErrorLevel
		Send, % Key
}