Autoit en español
Aplicaciones con Autoit - Juan Antonio Villalpando
-- Tutorial de iniciación a Autoit --
Volver al índice del tutorial
____________________________
47.- _IsPressed. HotKeySet.
- En el tutorial anterior vimos que mediante pulsando una tecla o varias a la vez mediante HotKeySet ejecutaremos a una función.
HotKeySet("{F2}", "Realizar_captura") ; Pulsar F2
HotKeySet("{ESC}", "Salir") ; Pulsar Escape
HotKeySet("{F3}", "Ventana_activa") ; Pulsar F3
HotKeySet("+{F2}", "Realizar_captura") ; Pulsar a la vez la tecla Mayúscula y F2
HotKeySet("^{F3}", "Ventana_activa") ; Pulsar a la vez la tecla Control y F3
- https://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm
- Nombre de las teclas: https://www.autoitscript.com/autoit3/docs/functions/Send.htm
- Ahora vamos a ver la función _IsPressed: https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm
- Para utilizarlo se ha de incluir:
#include <Misc.au3>
_____________________________________________________________________
- Sonidos.
- Al pulsar las teclas indicadas sonará un tono.
- El tono va subiendo una octava.
- Una octava significa el doble de la frecuencia.
Sonidos. |
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Pulsa ESC para salir", 613, 231, 192, 132)
; Juan A. Villalpando - KIO4.COM
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{ESC}", "Salir") ; Pulsar Escape para salir
$tiempo = 200
Local $hDLL = DllOpen("user32.dll")
While 1
If _IsPressed("41", $hDLL) Then Beep(100,$tiempo) ; A
If _IsPressed("53", $hDLL) Then Beep(200,$tiempo) ; S
If _IsPressed("44", $hDLL) Then Beep(400,$tiempo) ; D
If _IsPressed("46", $hDLL) Then Beep(800,$tiempo) ; F
If _IsPressed("47", $hDLL) Then Beep(1600,$tiempo) ; G
If _IsPressed("48", $hDLL) Then Beep(3200,$tiempo) ; H
If _IsPressed("4A", $hDLL) Then Beep(6400,$tiempo) ; J
If _IsPressed("4B", $hDLL) Then Beep(12800,$tiempo) ; K
WEnd
Func Salir()
DllClose($hDLL)
Exit
EndFunc
|
_____________________________________________________________________
- Ejemplo de pulsar teclas.
Ejemplo. |
#include <Misc.au3>
#include <MsgBoxConstants.au3>
Local $hDLL = DllOpen("user32.dll")
While 1
If _IsPressed("10", $hDLL) Then
ConsoleWrite("Pulsastes la tecla Mayúsculas." & @CRLF)
; Espera hasta que sueltes la tecla.
While _IsPressed("10", $hDLL)
Sleep(250)
WEnd
ConsoleWrite("Dejastes de pulsar la tecla Mayúsculas." & @CRLF)
ElseIf _IsPressed("1B", $hDLL) Then
MsgBox($MB_SYSTEMMODAL, "_IsPressed", "Has pulsado la tecla ESC, saldrás de la aplicación.")
ExitLoop
EndIf
Sleep(250)
WEnd
DllClose($hDLL)
|
__________________________________________
- Comentarios.
- ConsoleWrite, es la parte de abajo del editor, observa la imagen.
__________________________________________
- Propuestas.
- Realizar un órgano con las frecuencias apropiadas, do, re, mi, fa, sol, la, si.
- Otra librería de tipo IsPressed: https://www.autoitscript.com/forum/topic/86296-ispressed_udf-v23-advanced-keypress/
_____
|