smart hotkey

Ask gaming related questions (AHK v1.1 and older)
jugs90
Posts: 14
Joined: 22 Jan 2022, 18:53

smart hotkey

Post by jugs90 » 22 Jan 2022, 19:27

Hello everyone . I trying to write something by myself but its so difficult when never before you write any script. I see one script what is really nice but i want to a little bit change . I want when my hp on my character is red then i should to use ring(hotkey) and when i have diffrent color then switch off ring . Thats script works only when i have green color of my hp . How to fix it ? Maybe request is stupid but that help me alot !


Code: Select all

#SingleInstance, Force
CoordMode, Pixel, Screen
Loop
{
	If WinActive("Tibia")
	{
		PixelGetColor, Life20, 255, 0, RGB
		PixelGetColor, RingWorn, 1209, 272, RGB
		if (Life30 != 0xDB4F4F && RingWorn != 0x59E7B4) ; life is less than 20% and ring is not worn
			Send, {Home} ; put ring on

		PixelGetColor, Life90, 255, 0, RGB
		PixelGetColor, RingWorn, 1209, 272, RGB
		if (Life70 = 0xDB4F4F && RingWorn = 0x59E7B4) ; life is at least 70% and ring is worn
			Send, {Home} ; remove ring
	}
	Sleep, 2500
}
Return

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: smart hotkey

Post by mikeyww » 22 Jan 2022, 19:42

I'm not sure, but could you just switch the green color to the red one?

I think that you have some bugs with the variable names.

Code: Select all

red := 0xDB4F4F
Loop {
 WinWaitActive, Tibia
 Gosub, Ring
 SetTimer, Ring, 1000
 WinWaitNotActive
 SetTimer, Ring, Off
 SoundBeep, 1000
}
Ring:
SoundBeep, 1500
CoordMode, Pixel
PixelGetColor, Life    ,  255,   0, RGB
PixelGetColor, RingWorn, 1209, 272, RGB
If (Life != red && RingWorn != red
 || Life  = red && RingWorn  = red)
 Send {Home} ; Switch ring (on or off)
Return

jugs90
Posts: 14
Joined: 22 Jan 2022, 18:53

Re: smart hotkey

Post by jugs90 » 23 Jan 2022, 02:34

mikeyww wrote:
22 Jan 2022, 19:42
I'm not sure, but could you just switch the green color to the red one?

I think that you have some bugs with the variable names.

Code: Select all

red := 0xDB4F4F
Loop {
 WinWaitActive, Tibia
 Gosub, Ring
 SetTimer, Ring, 1000
 WinWaitNotActive
 SetTimer, Ring, Off
 SoundBeep, 1000
}
Ring:
SoundBeep, 1500
CoordMode, Pixel
PixelGetColor, Life    ,  255,   0, RGB
PixelGetColor, RingWorn, 1209, 272, RGB
If (Life != red && RingWorn != red
 || Life  = red && RingWorn  = red)
 Send {Home} ; Switch ring (on or off)
Return
Hey mate i will do that and still doent work correctly . Or maybe its possible to write script if hp is red then use hotkey ones ? without off on ?

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: smart hotkey

Post by mikeyww » 23 Jan 2022, 07:04

I do not have a way to test it. You may need to adjust the colors according to what you need.

jugs90
Posts: 14
Joined: 22 Jan 2022, 18:53

Re: smart hotkey

Post by jugs90 » 23 Jan 2022, 07:41

mikeyww wrote:
23 Jan 2022, 07:04
I do not have a way to test it. You may need to adjust the colors according to what you need.
Hey mate thanks for helping me .

Maybe its possible to write something like that . If hp is lower then 30 % then use ring ? i want find easy way to create it :)

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: smart hotkey

Post by mikeyww » 23 Jan 2022, 08:40

If you are looking for a color variation, one trick that people use is using PixelSearch instead of PixelGetColor. You search at just a single pixel location. By using PixelSearch, you can then include a variation parameter. Example

Post Reply

Return to “Gaming Help (v1)”