Need a basic script and help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Need a basic script and help

09 May 2023, 03:43

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! ^^
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

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.
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 04:11

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.
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

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.
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 04:37

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?
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

09 May 2023, 04:45

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?
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 04:51

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)
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

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
}
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 06:45

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
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

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.
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 07:00

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 🤙🏻
Galakrond
Posts: 26
Joined: 18 Dec 2022, 12:23

Re: Need a basic script and help

09 May 2023, 15:02

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}?
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Need a basic script and help

09 May 2023, 15:43

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
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 192 guests