Anular tecla usando return Topic is solved

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

Moderator: Flipeador

Archa

Anular tecla usando return

Post by Archa » 06 Jun 2021, 09:12

Holas.
Tengo este script. Cuando aparece una imagen en pantalla usa la hotkey de la "z", si no aparece la imagen teclea la "z" normal. Lo que yo querría es que cuando no hay imagen, al pulsar "z" tampoco se active la "z", como si hiciera z::return. La cosa es que he intentado varias cosas metiéndole el return pero no me funciona.

Script que funciona correctamente:----------------------------------------------------------------------------------------------------

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

loop
{
	ImageSearch, x, y, 0, 0, 1920, 1080, *10 Imagen.png
	if Errorlevel = 0
	{
		Hotkey, z, On
		Hotkey, z up, On
	}
	if Errorlevel
	{
		Hotkey, z, Off
		Hotkey, z up, Off
	}
}
return

z::Send {z down}

z up::
Send {z up}
Send {s down}
Send {s up}
return

Script que querría anular la Z cuando no hay imagen (no funciona):-----------------------------------------------------------------------------
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

Variable1 := 0

loop
{
	ImageSearch, x, y, 0, 0, 1920, 1080, *10 Imagen.png
	if Errorlevel = 0
	{
		Hotkey, $z, On
		Hotkey, $z up, On
		Variable1 := 1
	}
	if Errorlevel
	{
		Hotkey, $z, Off
		Hotkey, $z up, Off
		Variable1 := 0
                ;z::return ???
	}
}
return

$z::
if (Variable1 == 1)
Send {z down}
else
return
return

$z up::
if (Variable1 == 1)
{
Send {z up}
Send {s down}
Send {s up}
}
else
return
return
Last edited by SKAN on 06 Jun 2021, 09:40, edited 1 time in total.
Reason: Code tag applied

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: Anular tecla usando return  Topic is solved

Post by safetycar » 07 Jun 2021, 13:33

Code: Select all

#If FoundImageOnScreen("Imagen.png")
z::MsgBox Yes
#If
z::MsgBox No

FoundImageOnScreen(ImageFile) {
    ImageSearch, , , 0, 0, A_ScreenWidth, A_ScreenHeight, % ImageFile
    return (!ErrorLevel)
}

Archa

Re: Anular tecla usando return

Post by Archa » 08 Jun 2021, 03:10

safetycar mil gracias, eres un dios, funciona perfectiiiiiiisimo.

Post Reply

Return to “Pedir Ayuda”