Help With this code Topic is solved

Ask gaming related questions (AHK v1.1 and older)
nicolasaraya0309

Help With this code  Topic is solved

11 Feb 2018, 01:42

So ive tried everything but cant get this to work properly, i just want my Lbutton to be held down for a quick second so it clicks once
ive tried putting it to sleep but it wont work

Code: Select all

 Threshold = 20
;https://www.youtube.com/watch?v=rJZZi0dPphE&list=PLcmyfEZP-r3hU3UDPf__DZFvPkbxlAerY&index=3
*~$Xbutton1::
MouseGetPos, MouseX, MouseY
PixelGetColor, Color1, (MouseX+2), (MouseY+2)
StringSplit, Colorz, Color1
Color1B = 0x%Colorz3%%Colorz4%
Color1G = 0x%Colorz5%%Colorz6%
Color1R = 0x%Colorz7%%Colorz8%
Color1B += 0
Color1G += 0
Color1R += 0
 
while (GetKeyState("Xbutton1", "P"))
    {
        BlockInput, MouseMove
        sleep 1
        MouseGetPos, MouseX, MouseY
        PixelGetColor, Color2, (MouseX+2), (MouseY+2)
        StringSplit, Colorz, Color2
        Color2B = 0x%Colorz3%%Colorz4%
        Color2G = 0x%Colorz5%%Colorz6%
        Color2R = 0x%Colorz7%%Colorz8%
        Color2B += 0
        Color2G += 0
        Color2R += 0
        if (Color1R > (Color2R + Threshold)) or (Color1R < (Color2R - Threshold)) or (Color1G > (Color2G + Threshold)) or (Color1G < (Color2G - Threshold)) or (Color1B > (Color2B + Threshold)) or (Color1B < (Color2B - Threshold))
            {
                send {LButton}
            }
    }
BlockInput, MouseMoveOff
Return
 
End::
exitapp
return
User avatar
boiler
Posts: 17079
Joined: 21 Dec 2014, 02:44

Re: Help With this code

11 Feb 2018, 08:18

What are you saying the problem is? You don't want it to repeatedly click? You want a pause between clicks? Or you want it to only click once when the color is outside the threshold?
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Help With this code

11 Feb 2018, 09:36

May i just point out that your sleep is one millisecond? If you want one second sleep, try Sleep, 1000

Code: Select all

 Threshold = 20
;https://www.youtube.com/watch?v=rJZZi0dPphE&list=PLcmyfEZP-r3hU3UDPf__DZFvPkbxlAerY&index=3
*~$Xbutton1::
MouseGetPos, MouseX, MouseY
PixelGetColor, Color1, (MouseX+2), (MouseY+2)
StringSplit, Colorz, Color1
Color1B = 0x%Colorz3%%Colorz4%
Color1G = 0x%Colorz5%%Colorz6%
Color1R = 0x%Colorz7%%Colorz8%
Color1B += 0
Color1G += 0
Color1R += 0
 
while (GetKeyState("Xbutton1", "P"))
    {
        BlockInput, MouseMove
        sleep 1 ; <------------------------------------------------------------------------------------------ try 1000 instead?
        MouseGetPos, MouseX, MouseY
        PixelGetColor, Color2, (MouseX+2), (MouseY+2)
        StringSplit, Colorz, Color2
        Color2B = 0x%Colorz3%%Colorz4%
        Color2G = 0x%Colorz5%%Colorz6%
        Color2R = 0x%Colorz7%%Colorz8%
        Color2B += 0
        Color2G += 0
        Color2R += 0
        if (Color1R > (Color2R + Threshold)) or (Color1R < (Color2R - Threshold)) or (Color1G > (Color2G + Threshold)) or (Color1G < (Color2G - Threshold)) or (Color1B > (Color2B + Threshold)) or (Color1B < (Color2B - Threshold))
            {
                send {LButton}
            }
    }
BlockInput, MouseMoveOff
Return
 
End::
exitapp
return
Could try this as well and tell me if thats what you want?

Code: Select all

; Auto-Execute
#SingleInstance, Force
Count = 0
thershold=1250

~$LButton::
	if !(LButtonPressed=1)
	{
		LButtonPressed=1
		Count = 0
		SetTimer, CountTime, 1
	}
Return

~$LButton Up::
	LButtonPressed=0
	SetTimer, CountTime, Off
Return

CountTime:
	Count+=100
	if (Count>=thershold)
	{
		;send {LButton}
		tooltip, i clicked! :)
		SetTimer, CountTime, Off
	}
	else
		tooltip %Count%
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 53 guests