help with rbutton search pixel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
johnatan757
Posts: 7
Joined: 19 Oct 2023, 21:55

help with rbutton search pixel

28 Oct 2023, 11:01

hi, When I press the rbutton and lbutton to send the middle, the script below does not work, it stops giving search pixel, but if I release the buttons, and just hold the rbutton it gives searchpixel

Code: Select all

~RButton & ~LButton::
MouseClick, Middle
Sleep 10
KeyWait LButton
Return

Code: Select all

Loop, {
~RButton::
while GetKeyState("RButton")
{
if AimBotON = "True"
{	
Gui,Submit,NoHide
ScanL := ZeroX - CFovX
ScanR := ZeroX + CFovX
ScanT := ZeroY - CFovY
ScanB := ZeroY + CFovY
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB, EMCol, ColVn, Fast RGB 
GoSub GetAimOffset
GoSub GetAimMoves 
GoSub MouseMoves   
}
}
User avatar
mikeyww
Posts: 27241
Joined: 09 Sep 2014, 18:38

Re: help with rbutton search pixel

29 Oct 2023, 07:40

Ideas are below. This script demonstrates how you can troubleshoot and understand what your script does.

Tips:
1. Use indentation where appropriate. This provides a visual aid.
2. A hotkey cannot be defined via :: inside a loop or other control-flow statement.

Code: Select all

#Requires AutoHotkey v1.1.33

~RButton::
n := 0, str := ""
While GetKeyState("RButton", "P") {
 ToolTip % str .= "RB "
 Sleep 100
}
Return

~RButton & ~LButton::
ToolTip % str .= "Both "
While GetKeyState("RButton", "P") & GetKeyState("LButton", "P") {
 ToolTip % str .= ++n " "
 Sleep 100
}
Return
johnatan757
Posts: 7
Joined: 19 Oct 2023, 21:55

Re: help with rbutton search pixel

29 Oct 2023, 10:18

mikeyww wrote:
29 Oct 2023, 07:40
Ideas are below. This script demonstrates how you can troubleshoot and understand what your script does.

Tips:
1. Use indentation where appropriate. This provides a visual aid.
2. A hotkey cannot be defined via :: inside a loop or other control-flow statement.

Code: Select all

#Requires AutoHotkey v1.1.33

~RButton::
n := 0, str := ""
While GetKeyState("RButton", "P") {
 ToolTip % str .= "RB "
 Sleep 100
}
Return

~RButton & ~LButton::
ToolTip % str .= "Both "
While GetKeyState("RButton", "P") & GetKeyState("LButton", "P") {
 ToolTip % str .= ++n " "
 Sleep 100
}
Return
Good morning, thank you for trying to help me, is it possible to add a checkbox to make the script work?

Code: Select all

~RButton & ~LButton::
ToolTip % str .= "Both "
While GetKeyState("RButton", "P") & GetKeyState("LButton", "P") {
 ToolTip % str .= ++n " "
 Sleep 100
}
Return
User avatar
mikeyww
Posts: 27241
Joined: 09 Sep 2014, 18:38

Re: help with rbutton search pixel

29 Oct 2023, 10:38

GUI checkbox to enable selected hotkeys

Code: Select all

; This script creates a GUI that sets a context for selected hotkeys
#Requires AutoHotkey v1.1.33
guiPos := [A_ScreenWidth - 150, 155]        ; GUI position (x, y)
Gui +AlwaysOnTop +ToolWindow
Gui Font, s10
Gui Color, FFFF9E
Gui Add, Checkbox, w60 vactive gGo, &Active ; Enable or disable selected hotkeys
show(guiPos, "NoActivate")

F3::show(guiPos) ; F3 = Activate the GUI

; -----------------------------------------------
; Selected hotkeys
#If active
F4::MsgBox 123
#If
; -----------------------------------------------

Go:
Gui Submit, NoHide
Return

show(pos, option := "") {  ; Show the GUI
 Gui Show, % "x" pos[1] " y" pos[2] " " option, Status
}
johnatan757
Posts: 7
Joined: 19 Oct 2023, 21:55

Re: help with rbutton search pixel

30 Oct 2023, 16:42

mikeyww wrote:
29 Oct 2023, 10:38
GUI checkbox to enable selected hotkeys

Code: Select all

; This script creates a GUI that sets a context for selected hotkeys
#Requires AutoHotkey v1.1.33
guiPos := [A_ScreenWidth - 150, 155]        ; GUI position (x, y)
Gui +AlwaysOnTop +ToolWindow
Gui Font, s10
Gui Color, FFFF9E
Gui Add, Checkbox, w60 vactive gGo, &Active ; Enable or disable selected hotkeys
show(guiPos, "NoActivate")

F3::show(guiPos) ; F3 = Activate the GUI

; -----------------------------------------------
; Selected hotkeys
#If active
F4::MsgBox 123
#If
; -----------------------------------------------

Go:
Gui Submit, NoHide
Return

show(pos, option := "") {  ; Show the GUI
 Gui Show, % "x" pos[1] " y" pos[2] " " option, Status
}
Hi, So I tried adding the code

Code: Select all

~RButton & ~LButton::
ToolTip % str .= "Both "
While GetKeyState("RButton", "P") & GetKeyState("LButton", "P") {
 ToolTip % str .= ++n " "
 Sleep 100
}
Return
However, my searchpixel still doesn't work, the searchpixel is in the rbutton, and when I'm pressing rbutton+lbutton like the code, it's sending the middle directly, whereas it was supposed to send just one, while pressing the 2 buttons
User avatar
mikeyww
Posts: 27241
Joined: 09 Sep 2014, 18:38

Re: help with rbutton search pixel

30 Oct 2023, 17:54

Please post your revised script in a new reply.
johnatan757
Posts: 7
Joined: 19 Oct 2023, 21:55

Re: help with rbutton search pixel

30 Oct 2023, 18:35

mikeyww wrote:
30 Oct 2023, 17:54
Please post your revised script in a new reply.

Code: Select all

#Persistent
    #KeyHistory, 0
    #NoEnv
    #HotKeyInterval 1
    #MaxHotkeysPerInterval 127
    #InstallKeybdHook
    #UseHook
    #SingleInstance, Force
    #Persistent ; (Interception hotkeys do not stop AHK from exiting, so use this)
    #include Lib\AutoHotInterception.ahk
    global AHI := new AutoHotInterception()
     
EMCol := "0xc9008d"                                                                                                                 
 
SetKeyDelay,-1, 8
SetControlDelay, -1
SetMouseDelay, -1
SetWinDelay,-1
SendMode, InputThenPlay
SetBatchLines,-1
ListLines, Off
CoordMode, Pixel, Screen, RGB
CoordMode, Mouse, Screen
PID := DllCall("GetCurrentProcessId")
Process, Priority, %PID%, High 
autoadjustedwidth := (A_ScreenWidth // 2)
autoadjustedheight := (A_ScreenHeight // 2)
AimBotON = "false"
PingR = "false"
PingRL = "false"
Loop, 10
{
    ConfigFile2 = Config%A_Index%.ini
    if (FileExist(ConfigFile2)) 
    {
    }
    Else
    {
    IniWrite, 38, %ConfigFile2%, main, ColVn
    IniWrite, %autoadjustedwidth%, %ConfigFile2%, main, ZeroX
    IniWrite, %autoadjustedheight%, %ConfigFile2%, main, ZeroY
    IniWrite, 0, %ConfigFile2%, main, CFovX
    IniWrite, 0, %ConfigFile2%, main, CFovY
    IniWrite, 0, %ConfigFile2%, main, CSmoothX
    IniWrite, 0, %ConfigFile2%, main, CSmoothY
    IniWrite, 0, %ConfigFile2%, main, Ingamesensitivity
    IniWrite, 0, %ConfigFile2%, main, BustSpeed
    }
}

Gui, Color, Black
Gui, Font, cRed
Gui, Add, Text, x35 y245 , Cor Ping=
Gui, Add, Edit, x105 y243 w45 h20 , c9008d
Gui, Add, Text, x72 y19 w40 h20 , ColVn=
Gui, Add, Text, x72 y39 w40 h20 , ZeroX=
Gui, Add, Text, x72 y59 w40 h20 , ZeroY=
Gui, Add, Text, x72 y79 w40 h20 , CFovX=
Gui, Add, Text, x72 y99 w40 h20 , CFovY=
Gui, Add, Text, x52 y119 w60 h20 , CSmoothX=
Gui, Add, Text, x52 y139 w60 h20 , CSmoothY=
Gui, Add, Text, x22 y159 w90 h20 , Ingamesensitivity=
Gui, Add, Text, x52 y179 w60 h20 , BustSpeed=
Gui, Add, Edit, x112 y19 w40 h20 +VColVn, 38
Gui, Add, Edit, x112 y39 w40 h20 +VZeroX, %autoadjustedwidth%
Gui, Add, Edit, x112 y59 w40 h20 +VZeroY, %autoadjustedheight%
Gui, Add, Edit, x112 y79 w40 h20 +VCFovX, 45
Gui, Add, Edit, x112 y99 w40 h20 +VCFovY, 45
Gui, Add, Edit, x112 y119 w40 h20 +VCSmoothX, 1
Gui, Add, Edit, x112 y139 w40 h20 +VCSmoothY, 1
Gui, Add, Edit, x112 y159 w40 h20 +VIngamesensitivity, 10
Gui, Add, Edit, x112 y179 w40 h20 +VBustSpeed, 0.14
Gui, Add, Button, x168 y40 w90 h26 gsub1, Save
Gui, Add, Button, x168 y65 w90 h26 gsub2, Load
Gui, Add, Button, x55 y205 w90 h32 gsub5, Resolucao Automatica
Gui, Add, Button, x168 y149 w90 h26 gsub6, AimAssist ON
Gui, Add, Button, x168 y174 w90 h26 gsub7, AimAssist OFF
Gui, Add, DropDownList, x168 y18 w90 h150 +Vchoice, Config1|Config2|Config3|Config4|
Gui, Show, x437 y347 h270 w307, Aim Assist
Winset, Alwaysontop, On, A
Return

sub1:
{
gui,submit,nohide
configfile = %choice%.ini
IniWrite, %ColVn%, %configfile%, main, ColVn
IniWrite, %ZeroX%, %configfile%, main, ZeroX
IniWrite, %ZeroY%, %configfile%, main, ZeroY
IniWrite, %CFovX%, %configfile%, main, CFovX
IniWrite, %CFovY%, %configfile%, main, CFovY
IniWrite, %CSmoothX%, %configfile%, main, CSmoothX
IniWrite, %CSmoothY%, %configfile%, main, CSmoothY
IniWrite, %Ingamesensitivity%, %configfile%, main, Ingamesensitivity
IniWrite, %BustSpeed%, %configfile%, main, BustSpeed
gui,submit,nohide
return
}
sub2:
{
gui,submit,nohide
configfile = %choice%.ini
IniRead, ColVn, %configfile%, main, ColVn
IniRead, CFovX, %configfile%, main, CFovX
IniRead, CFovY, %configfile%, main, CFovY
IniRead, ZeroX, %configfile%, main, ZeroX
IniRead, ZeroY, %configfile%, main, ZeroY
IniRead, CSmoothX, %configfile%, main, CSmoothX
IniRead, CSmoothY, %configfile%, main, CSmoothY
IniRead, Ingamesensitivity, %configfile%, main, Ingamesensitivity
IniRead, BustSpeed, %configfile%, main, BustSpeed
GuiControl,, ColVn, %ColVn%
GuiControl,, CFovX, %CFovX%
GuiControl,, CFovY, %CFovY%
GuiControl,, ZeroX, %ZeroX%
GuiControl,, ZeroY, %ZeroY%
GuiControl,, CSmoothX, %CSmoothX%
GuiControl,, CSmoothY, %CSmoothY%
GuiControl,, Ingamesensitivity, %Ingamesensitivity%
GuiControl,, BustSpeed, %BustSpeed%
gui,submit,nohide
return
}
sub5:
{
GuiControl,, ZeroX, %autoadjustedwidth%
GuiControl,, ZeroY, %autoadjustedheight%
return
}
sub6:
{
    gui,submit,nohide
AimBotON = "true"
    gui,submit,nohide
return
}
sub7:
{
    gui,submit,nohide
AimBotON = "false"
    gui,submit,nohide
return
}

Loop, {
~RButton::
while GetKeyState("RButton")
{
if AimBotON = "True"
{	
Gui,Submit,NoHide
ScanL := ZeroX - CFovX
ScanR := ZeroX + CFovX
ScanT := ZeroY - CFovY
ScanB := ZeroY + CFovY
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB, EMCol, ColVn, Fast RGB 
GoSub GetAimOffset
GoSub GetAimMoves 
GoSub MouseMoves   
}
}
 
GetAimOffset:
 AimX := AimPixelX - ZeroX
 AimY := AimPixelY - ZeroY
 AimY := AimPixelY+3 - ZeroY
 
  If ( AimX > 0 ) {
   DirX := 1
  }
  If ( AimX < 0 ) {
   DirX := -1
  }
  If ( AimY > 0 ) {
   DirY := 1
  }
  If ( AimY < 0 ) {
   DirY := -1
  }
 AimOffsetX := AimX * DirX
 AimOffsetY := AimY * DirY 
Return
 
GetAimMoves:
 RootX := Ceil(( AimOffsetX ** 1))
 RootY := Ceil(( AimOffsetY ** 1))
 MoveX := (RootX * DirX) / CSmoothX
 MoveY := (RootY * DirY) / CSmoothY
Return
 
MouseMoves:
 MoveMultipler := ((0.0066 * 1.50 * 1) / BustSpeed)
 AHI.SendMouseMove(11, MoveX * MoveMultipler, MoveY * MoveMultipler)
 return
}
return

~RButton & ~LButton::
MouseClick, Middle
Sleep 10
KeyWait LButton
Return

GuiClose:
ExitApp
User avatar
mikeyww
Posts: 27241
Joined: 09 Sep 2014, 18:38

Re: help with rbutton search pixel

30 Oct 2023, 19:05

I recommend that you debug your script. How to do it? I would start by shortening the script to a few essential parts that you would like to test. If your pixel search does not work, then troubleshoot it by displaying the ErrorLevel immediately after the search. Although I already indicated that a hotkey cannot be defined via :: inside a loop or other control-flow statement, you have done that anyway. Finally, regarding "it's sending the middle directly, whereas it was supposed to send just one, while pressing the 2 buttons", I do not know what this means.

Start with a short script that works. Add to it iteratively, little by little, with iterative testing so that you can understand when the script stops working, and what made it so.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Chunjee, mikeyww, Raghava Doregowda and 107 guests