by marcosrob » 16 Jun 2021, 14:47
Boa tarde.
Estou tentando fazendo um macro de no recoil, quero que ele ative quando der um click com botão direito e desative quando der outro click com mesmo botão.
O primeiro click funciona, mas quando clico novamente com botão direito nada faz.
Como fazer para reconhecer o segundo click e parar a repetição?
Obrigado.
Code: Select all
#NoEnv
SendMode Input
F1::ExitApp ; F1 used to exit the ahk script file
F2::Pause ; F2 pause
~RButton::
click := 0
if GetKeyState("RButton", "P")
{
while (click = 0)
{
_auto := true ;Toggle for the anti-recoil being on or off. default is on
~LButton::autofire() ; When the LButton is pressed run the autofire() function
!LButton::_auto := ! _auto ;Alt + F2 used to toggle the anti-recoil on and off
; autofire() function, name is misleading could easily be antiRecoil()
autofire()
{
global _auto
if _auto ; if _auto == true. i.e. is anti-recoil on?
{ ; anti-recoil on? If yes do this
Loop ; Continuously loop until a 'break' command
{
if GetKeyState("LButton", "P") ; If LButton is pressed
{ ; LButton pressed? If yes do this
Sleep 75 ; sleep for 75 milliseconds
mouseXY(0,-15) ;Call the mouseXY() function which moves the mouse the specified distance. mouseXY( X, Y,)
Sleep 45 ; sleep for 45 milliseconds
}
else ;LButton pressed? If no do this, i.e. exit the loop
break ;will stop the loop
} ;; loop
} ;; if
} ;; autofire() ; anti-recoil on? If no do nothing
mouseXY(x,y)
{
DllCall("mouse_event",uint,1,int,x,int,y,uint,0,int,0) ; moves the mouse could easily be the built in autohotkey MouseMove, X, Y
}
}
}
[Mod edit: [code][/code] tags added.]
Boa tarde.
Estou tentando fazendo um macro de no recoil, quero que ele ative quando der um click com botão direito e desative quando der outro click com mesmo botão.
O primeiro click funciona, mas quando clico novamente com botão direito nada faz.
Como fazer para reconhecer o segundo click e parar a repetição?
Obrigado.
[code]#NoEnv
SendMode Input
F1::ExitApp ; F1 used to exit the ahk script file
F2::Pause ; F2 pause
~RButton::
click := 0
if GetKeyState("RButton", "P")
{
while (click = 0)
{
_auto := true ;Toggle for the anti-recoil being on or off. default is on
~LButton::autofire() ; When the LButton is pressed run the autofire() function
!LButton::_auto := ! _auto ;Alt + F2 used to toggle the anti-recoil on and off
; autofire() function, name is misleading could easily be antiRecoil()
autofire()
{
global _auto
if _auto ; if _auto == true. i.e. is anti-recoil on?
{ ; anti-recoil on? If yes do this
Loop ; Continuously loop until a 'break' command
{
if GetKeyState("LButton", "P") ; If LButton is pressed
{ ; LButton pressed? If yes do this
Sleep 75 ; sleep for 75 milliseconds
mouseXY(0,-15) ;Call the mouseXY() function which moves the mouse the specified distance. mouseXY( X, Y,)
Sleep 45 ; sleep for 45 milliseconds
}
else ;LButton pressed? If no do this, i.e. exit the loop
break ;will stop the loop
} ;; loop
} ;; if
} ;; autofire() ; anti-recoil on? If no do nothing
mouseXY(x,y)
{
DllCall("mouse_event",uint,1,int,x,int,y,uint,0,int,0) ; moves the mouse could easily be the built in autohotkey MouseMove, X, Y
}
}
}[/code][color=#FF0040][size=75][Mod edit: [kbd][code][/code][/kbd] tags added.][/size][/color]