Problema con los modificadores

Esta sección es para preguntas sobre programación/scripting usando AutoHotkey.

Moderator: Flipeador

Westisback
Posts: 2
Joined: 25 Aug 2023, 05:30

Problema con los modificadores

25 Aug 2023, 06:05

Empece hace 1 dia con autohotkey y estoy probando el autoclick a ver que tal iba, el problema es que si lo quiero usarlo en un juego, y me quiero agachar al mismo tiempo que se usa no puedo, porque mi tecla de agacharse es el ctrl. Por lo que tengo entendido es por eso que no va y no se si puedo meter un codigo o algo para anular el control como modificador o algo, espero que alguien me pueda echar un cable, gracias de antemano ^^


Aqui el codigo:

Code: Select all

#MaxThreadsPerHotkey 2


;Collect my cropies
f::
{


	{
   	Toggle:=!Toggle

  	 While, Toggle
  	  {
		Send {LButton}
		Sleep, 33
        }
	   }

}


return,

;Put my cropies

+Z::
{

	{
		
		Toggle:=!Toggle
	 
		While, Toggle
		 {
			 Send {RButton}
			 Sleep, 33
			 Send {LControl}
		 }
	 }

}
return,
[Mod edit: + [code][/code] tags.]
User avatar
ositoMalvado
Posts: 183
Joined: 24 Dec 2019, 12:02
Contact:

Re: Problema con los modificadores

25 Aug 2023, 18:08

Bienvenido al foro amigo, en mi respuesta te presento una clase que hice para simplificar el uso de TOGGLE con funciones repetitivas o bien timers o intervalos

Puedes ver la clase que utilizo en la siguiente página (aunque lo hice en inglés)

Prueba el siguiente código, es una representación de lo que quieres hacer, espero que te funcione, si tienes algun problema no dudes en consultar.

Code: Select all

delay:=33
tog_f:=new func2timer("f_action",delay)
tog_z:=new func2timer("z_action",delay)

f_action(){
	Send {LButton}
}

z_action(){
	Send {RButton}
	Sleep, %delay%
	Send {LControl}
}


f::tog_f.toggle()
+z::tog_z.toggle()

;
;               CLASS CREATED BY OSITOMALVADO
;
;
;   This class simplifies the creation and use of intervals.
; You can make the function you want to repeat with a single
; line. You can also add a function that will be executed at
; the beginning and another at the end (you must add the
; initials "Start" and "Stop" to your interval function respectively)
;
;
;   Constructor: receives a base function which can have
;associated "Start" and "Stop"
;
;       Using:
;
;   getToggleState()
;   Return 1 if interval is on, else return 0
;
;   toggle()
;   If interval is on will be turned off, else will be turned on
;
;
;   start()
;   This function just start the interval, if this.function "Start" exist will be executed before the interval
;
;   tick()
;   This is the main function that will make the interval work, this is every step
;
;   stop()
;   Same as start but this is for the end

class func2timer{
    state:=False
   __New(fun,delay:=0){
      if !IsFunc(fun)
         return ErrorLevel
      this.function:=fun
      this.initFunction:=this.function "Start"
      this.endFunction:=this.function "Stop"
      this.delay:=delay
      this.timer:=ObjBindMethod(this, "tick")
   }
   getToggleState(){
    Return this.state
   }
   toggle(){
    this.state:=!this.state
    if (this.state)
        this.start()
    Else
        this.stop()
   }
   start(){
      if IsFunc(this.initFunction)
         this.initFunction(this)
      timer:=this.timer
      SetTimer, % timer, % this.delay
   }
   tick(){
      if IsFunc(this.function)
         this.function(this)
   }
   stop(){
      timer:=this.timer
      SetTimer, % timer,Off
      if IsFunc(this.endFunction)
         this.endFunction(this)
   }
}
My WEB some useful stuff

Return to “Pedir Ayuda”

Who is online

Users browsing this forum: No registered users and 9 guests