Hello, i'm disabled and using ahk i've been able to play many games that normally i couldn't, recently i was playing a game and i'm sure everyone one here knows of or has heard of Diablo 2.
I was struggling with the potions because they require four buttons, keys 1, 2, 3 and 4. I had an idea for a script but i'm not entirely sure how to go about making it work. It would work something like this....
1.Press hotkey
2. Search x1,y1 for color
3. if color found press 1 and end script
4. if color not found search x2,y2
do this for keys 1,2,3 and 4
If anyone has a idea please post!
Color detection and key press script
-
- Posts: 36
- Joined: 12 Mar 2020, 02:56
Re: Color detection and key press script
Code: Select all
$1::
targetColor := 0xFFFFFF ; Blue, green, red
PixelGetColor, thisColor, x1, y1
If (thisColor != targetColor)
PixelGetColor, thisColor, x2, y2
Send % thisColor = targetColor ? SubStr(A_ThisHotkey, 0) : ""
Return
-
- Posts: 36
- Joined: 12 Mar 2020, 02:56
Re: Color detection and key press script
Would you be able to give me an example with Target color/cords for x1,y1 and x2,y2. I tried to edit the parts i could understand.
Sorry this is extremely new to me, i really appreciate your time.
[Mod edit: [code][/code] tags added.]
Sorry this is extremely new to me, i really appreciate your time.
Code: Select all
$1::
targetColor := 0xC1bf36 ; i added my color. ;0xFFFFFF ; Blue, green, red
PixelGetColor, thisColor, x1, y1
If (thisColor != targetColor)
PixelGetColor, thisColor, x2, y2
;If (thisColor != targetColor)
;PixelGetColor, thisColor, x3, y3
;If (thisColor != targetColor)
;PixelGetColor, thisColor, x4, y4
Send % thisColor = targetColor ? SubStr(A_ThisHotkey, 0) : ""
Return
;Target Color 0xC1bf36
;x1, y1 ;top left to Bottom right
;Key to press if target color detected {1}
/*
;Screen 1619,777
;window 983,777
;client 973,738
;Screen 1066,821
;window 1030,821
;client 1020, 782
*/
;----------------------
;x2, y2 ;top left to Bottom right
;Key to press if target color detected {2}
/*
;Screen 1672,777
;window 1036,777
;client 1026,738
;Screen 1716,821
;window 1080,821
;client 1080,782
*/
;----------------------
;x3, y3 ;top left to Bottom right
;Key to press if target color detected {3}
/*
;Screen 1723,777
;window 1087,777
;client 1077,738
;Screen 1775,821
;window 1139,821
;client 1129,782
*/
;----------------------
;x4, y4 ;top left to Bottom right
;Key to press if target color detected {4}
/*
;Screen 1174,777
;window 1138,777
;client 1128,738
;Screen 1824,821
;window 1188,821
;client 1178,782
*/
Re: Color detection and key press script
You would need to describe exactly what should happen, step by step, with examples. If you intend to find a location's color, use PixelGetColor. If you intend to find a color's location, use PixelSearch.
-
- Posts: 36
- Joined: 12 Mar 2020, 02:56
Re: Color detection and key press script
Ok so let me explain.
So i use voice recognition to play majority of my games and being as potions juggle around the key is always different.
In the game i play theres a belt with potions and the potions are constantly juggling around the belt
the belt has 4 slots from left to right labeled with hotkeys to drink a potion.
Slot 1=1/Slot 2=2/Slot 3=3/Slot 4=4
[Mod edit: Image fixed, twice.]
So for the script i want it to look for a target color in slot 1, if it finds the target color it'll Press the 1 key the script reloads and stops looking.
If the Target color isn't in slot 1, i want to search slot 2 for the same target color, if it finds the target color it'll Press the 2 key the script reloads and stops looking.
If the Target color isn't in slot 2, i want to search slot 3 for the same target color, if it finds the target color it'll Press the 3 key the script reloads and stops looking.
If the Target color isn't in slot 3, i want to search slot 4 for the same target color, if it finds the target color it'll Press the 4 key the script reloads and stops looking.
I hope i explained correctly.
So i use voice recognition to play majority of my games and being as potions juggle around the key is always different.
In the game i play theres a belt with potions and the potions are constantly juggling around the belt
the belt has 4 slots from left to right labeled with hotkeys to drink a potion.
Slot 1=1/Slot 2=2/Slot 3=3/Slot 4=4
[Mod edit: Image fixed, twice.]
So for the script i want it to look for a target color in slot 1, if it finds the target color it'll Press the 1 key the script reloads and stops looking.
If the Target color isn't in slot 1, i want to search slot 2 for the same target color, if it finds the target color it'll Press the 2 key the script reloads and stops looking.
If the Target color isn't in slot 2, i want to search slot 3 for the same target color, if it finds the target color it'll Press the 3 key the script reloads and stops looking.
If the Target color isn't in slot 3, i want to search slot 4 for the same target color, if it finds the target color it'll Press the 4 key the script reloads and stops looking.
I hope i explained correctly.
Re: Color detection and key press script
Code: Select all
F3::
For slot, x in [[983, 1030], [1036, 1080], [1087, 1139], [1138, 1188]] {
PixelSearch,,, % x.1, 777, % x.2, 821, 0xFFFFFF,, Fast ; Blue, green, red
If ErrorLevel
Continue
Send %slot%
Break
}
Return
-
- Posts: 36
- Joined: 12 Mar 2020, 02:56
Re: Color detection and key press script
Hey, sorry i still don't understand where in the code its determining what hotkey it presses or not.
Re: Color detection and key press script
See Send. slot will be a number from 1 to 4. You can do a simulation by displaying the coordinates and removing the "If" and "Continue" statements.