Click Speed/delay/sleep Topic is solved

Ask gaming related questions (AHK v1.1 and older)
S1lver
Posts: 23
Joined: 07 Nov 2020, 04:14

Re: Click Speed/delay/sleep

Post by S1lver » 13 Dec 2023, 05:55

can we somehow add variation to the color it search for?

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
I have tried

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
ColorVariation := 20
and

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
Tolerance := 20
but nothing seems to work?

[Mod edit: [code][/code] tags added. Please use them yourself when posting code!]

S1lver
Posts: 23
Joined: 07 Nov 2020, 04:14

Re: Click Speed/delay/sleep

Post by S1lver » 13 Dec 2023, 06:07

I have been testing out the script for a while now, And I first now figured out something is wrong with the entire mechanism of delay.
if you have 5 active Panels, all but one is set to activate every 1000ms, and the one is set to activate every 31000 ms. the whole script is only responding to 31000 ms. Also I cannot deactivate the script before 31000 ms has passed.
I see it's a lot of work that has to be done, I tried using chatgpt to help us fix it. but I could not succeded with it.
I wish you a merry Christmas and I wish for the new year to have a spotlight on this matter.
cheers friend

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Click Speed/delay/sleep

Post by Hellbent » 19 Dec 2023, 15:38

S1lver wrote:
13 Dec 2023, 05:55
can we somehow add variation to the color it search for?

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
I have tried

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
ColorVariation := 20
and

Code: Select all

Main.Panels[ 1 ].SearchColor := "ff6eff"
Tolerance := 20
but nothing seems to work?
I ended up having to put off writing the script for a few months and ended up just doing it to get it done.
I did have a panel design that would have used variation.

Image

But for whatever reason I went with the current design.

If you want to add variation you would have to either hard code the value or modify the gui to have an edit control that you can use as the input (see the above picture)

As for doing the search, you can use this function to convert the hex color to decimal format to test if it is in the range you want.

Code: Select all

;*****************************************************
RGBtoHEXandBack(clr) {
   If (StrLen(clr)=9)
   {
      R := SubStr(clr, 1, 3)
      G := SubStr(clr, 4, 3)
      B := SubStr(clr, 7, 3)
      z := Format("{1:02x}", R) Format("{1:02x}", G) Format("{1:02x}", B)
  } Else
  {
      R := "0x" SubStr(clr, 1, 2)
      G := "0x" SubStr(clr, 3, 2)
      B := "0x" SubStr(clr, 5, 2)
      z := Format("{1:03d}", R) Format("{1:03d}", G) Format("{1:03d}", B)
  }

  Return z
}
;**********************************************************************
Here is an example of how to use it.

Code: Select all

;convert hex to dec
SelectedColor := "0xFF0000"
RGBDec := RGBtoHEXandBack( SelectedColor )
R := SubStr( RGBDec , 1 , 3 ) , G := SubStr( RGBDec , 4 , 3 ) , B := SubStr( RGBDec , 7 , 3 )

;convert dec to hex
RGBHex := RGBtoHEXandBack( R G B )
;or
RGBHex := RGBtoHEXandBack( RGBDec )
once you convert the color to decimal you can test each of the components for the current color and the target color to see if they are within your range.

example: (pseudo code)

Code: Select all

convert Target color to dec and split into r,g,b values
PixelGetColor, currentColor , x , y , RGB 
convert current color to dec and split into r,g,b values
if !( current_R - variation >= target_R && current_R + variation <= target_R )
	return
do the same for G and B
if you get here you are in target range, do your action.
To add that in you just need to find where the "PixelGetColor" command is used and edit the current search and match logic with the code from above.

I have been testing out the script for a while now, And I first now figured out something is wrong with the entire mechanism of delay.
if you have 5 active Panels, all but one is set to activate every 1000ms, and the one is set to activate every 31000 ms. the whole script is only responding to 31000 ms. Also I cannot deactivate the script before 31000 ms has passed.
I see it's a lot of work that has to be done, I tried using chatgpt to help us fix it. but I could not succeded with it.
I wish you a merry Christmas and I wish for the new year to have a spotlight on this matter.
cheers friend
You can split the delay into 1 second intervals and use a loop with a test of the value of the "Stop" variable.
Something like this (pseudo code)

Code: Select all

delay := 36000
remainder := mod( delay / 1000 )
nDelay := floor( delay / 1000 )
loop, % nDelay	{
	if( Stop )
		return
	sleep, 1000	
}
sleep, remainder

Post Reply

Return to “Gaming Help (v1)”