Isolate sleep within {} Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Isolate sleep within {}

Post by kentpachi » 03 Dec 2022, 06:49

Code: Select all

loop
{
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 981, 1012, 981, 1012, 0x3FDE45, 0, Fast RGB
If ErrorLevel = 0

	{


  ; check thirst
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1792, 975, 1792, 975, 0x3CD241, 20, Fast RGB
If ErrorLevel
        {
	  Send, {5 down}
        Sleep 20
        Send, {5 up}
		sleep, 1500	
		}





; check hunger
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1601, 975, 1601, 975, 0x3FDE45, 5, Fast RGB
If ErrorLevel
	     {
	  Send, {4 down}
        Sleep 20
        Send, {4 up}
		sleep, 1500	
		}





; check sleep
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 406, 1007, 406, 1007, 0xD3704C, 0, Fast RGB
If ErrorLevel = 0
  {
	   Send, {7 down}
       Sleep 20
       Send, {7 up}
	   sleep 200
	   Send, {8 down}
       Sleep 20
       Send, {8 up}
       sleep, 1200	
  }

	
	
	
	
	
	}


}

How do you make the sleep function isolate only inside the { } ?
currently when the sleep activate, it sleep the whole script.
There is a hunger, thirst and disease pixelsearch, How to make it when the sleep activated, it will only sleep within the { } and it will not sleep the whole script.
Example it found the hunger pixel, it will sleep the hunger script but will continue to search for thirst and disease script.


[Mod edit: Changed inline code tags (c) to [code][/code] tags. Please use the proper tags when posting code.]

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Isolate sleep within {}  Topic is solved

Post by Rohwedder » 03 Dec 2022, 08:44

Hallo,
something like "isolate the Sleep" Autohotkey can not do!
Study: Threads
In my scripts I try to replace longer Sleeps with Timers.

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: Isolate sleep within {}

Post by kentpachi » 03 Dec 2022, 11:09

Rohwedder wrote:
03 Dec 2022, 08:44
Hallo,
something like "isolate the Sleep" Autohotkey can not do!
Study: Threads
In my scripts I try to replace longer Sleeps with Timers.
could you reconstruct my sample script with that timer please?
I always learn from the sample script, if possible please make it short so I could easily understand and adapt it to my other scripts.

Hopefully ahk add that feature to isolate sleep within { }

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Isolate sleep within {}

Post by Rohwedder » 03 Dec 2022, 11:33

1. A script with PixelSearchs is not suitable as an example script, because a user can manipulate PixelSearch result and thus the flow only very awkwardly. Build something based on KeyWaits.
2. Threads have you read and understood this?

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: Isolate sleep within {}

Post by kentpachi » 04 Dec 2022, 12:03

Rohwedder wrote:
03 Dec 2022, 11:33
1. A script with PixelSearchs is not suitable as an example script, because a user can manipulate PixelSearch result and thus the flow only very awkwardly. Build something based on KeyWaits.
2. Threads have you read and understood this?
unfornutely no :(, anyways I will just make multiple ahk for now and hope in the future they add this kind of feature.

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Isolate sleep within {}

Post by Rohwedder » 05 Dec 2022, 04:13

This kind of feature, which I think you are actually looking for but can't articulate due to lack of willingness to learn, has already been added to Ahk_L:
AutoHotkey_H
AutoHotkey_H adds functionality to original AutoHotkey and offers true multi-threading using NewThread() function (v2 only) and AutoHotkey.dll.
However, this is something for big-boys only!

Post Reply

Return to “Gaming Help (v1)”