AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones varias de Windows
  • How to specify the keystrokes or the mouse actions to perform?
  • Miscellaneous
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Simulates the keystrokes and the mouse actions. SendKey can send keystrokes or mouse actions to any application intended to be run in a Windows environment.
Attention Under Windows Vista and higher, if the UAC mechanism is activated, the function SendKey function doesn't work properly: it's possible to send keys to the current process, but to send keys to another process, it's necessary to raise the application's rights (with a manifest, for example).
Ejemplo
EXTERN "KeyConst.wl"
i is int
// Runs the Calculator application
ExeRun("Calc.exe", exeActive)
// Wait for the calculator to be loaded
Multitask(50)
// Defines the count loop
FOR i = 1 TO 100
	// Send the keys to the Calculator application
	SendKey(NumToString(i) + "{+}")
END
// Reads the final total
SendKey("=")

// Wait
Multitask(100)

// Sends Alt+F4 to close the Calculator application
SendKey("%{F4}")
// Simulates a right mouse click on a table column
// A table column has no handle so we give it focus to compensate
SetFocus(TABLE_CustomerTable.COL_CustomerName)
// Send the right click
SendKey("{RIGHTBTN,1,1}", TABLE_CustomerTable.COL_CustomerName)
// Expand the "&File" menu of a main window
SendKey("%&f")
// Expand the "&File .. &New" menu of main window
SendKey("%&fn")
Sintaxis

Sending keystrokes or mouse actions to a window or to a control identified by its handle Ocultar los detalles

<Result> = SendKey(<Key or mouse> [, <Handle of window or control>])
<Result>: Boolean
  • True if the keystrokes were successfully sent,
  • False otherwise.
<Key or mouse>: Character string
Mouse actions or keystrokes to run. Each key is represented by one or more characters (see the notes).
<Handle of window or control>: Optional integer
Handle of window (or control) to which the keystrokes will be sent. If this parameter is not specified, the keystrokes are sent to the current window.
The handle of a window or control is returned by Handle or SysWinHandle.

Sending keystrokes or mouse actions to a window or to a control identified by its name Ocultar los detalles

<Result> = SendKey(<Key or mouse> [, <Name of window or control>])
<Result>: Boolean
  • True if the keystrokes were successfully sent,
  • False otherwise.
<Key or mouse>: Character string
Mouse actions or keystrokes to run. Each key is represented by one or more characters (see the notes).
<Name of window or control>: Optional character string
Name or alias of the window (or control) to which the keystrokes must be sent. If this parameter is not specified, the keystrokes are sent to the current window.
Observaciones

How to specify the keystrokes or the mouse actions to perform?

The <Key or mouse> parameter corresponds to the mouse actions or to the keystrokes used to run the shortcut. Each key is represented by one or more characters. There is no need to specify "Ctrl-Alt" that is automatically added. No shortcut key is specified by default.
To use a single keyboard character, you must use the character itself. For example, to represent the letter A, assign the value "A" to <Key or mouse>. To use a set of characters, use the set of characters directly ("ADB").
Caution: The function gives a special meaning to the following signs:
  • plus (+),
  • insertion (^),
  • percentage (%),
  • brackets ( ).
To use one of these characters, the character must be enclosed in curly brackets. For example, to use the plus sign (+), type {+}. To use curly brackets, use the {{} and {}} characters.
To use special characters, specific codes are required to identify:
  • the characters with no action on the screen (the Enter key for example),
  • the characters corresponding to an action (the function keys for example).
You must use the following codes:
KeyCodeKeyCode
BACKSPACE{BS}PAUSE{PAUSE}
CAPSLOCK{VERRMAJ}DEL{SUPPR}
DOWN{DOWN}END{END}
ENTER{ENTER}ESC{ECHAP}
HELP{HELP}HOME{HOME}
INSERT{INS}LEFT{LEFT}
NUMLOCK{NUMLOCK}PGDN{PGDN}
PGUP{PGUP}PRNT. SCREEN{PRTSC}
RIGHT{RIGHT}SCROLLLOCK{SCROLLLOCK}
TAB{TAB}TOP{TOP}
F1{F1}F2{F2}
F3{F3}F4{F4}
F5{F5}F6{F6}
F7{F7}F8{F8}
F9{F9}F10{F10}
F11{F11}F12{F12}
F13{F13}F14{F14}
F15{F15}F16{F16}
+ on the numeric keypad{NUM+}- on the numeric keypad{NUM-}

To specify a key combination with Shift, Ctrl or Alt, the standard key code must be preceded by one or more codes chosen among the following ones:
KeyCode
SHIFT+
Ctrl^
ALT%

To specify that the Shift, Ctrl and/or Alt keys are held down while another key is pressed while another key is pressed: for example, to hold down the Shift key at the same time as the E key, use "+e".
To specify that a key must be repeated, you must use an expression such as {<Key> <Number>}. Note: There must be a space between the <Touche> and <Nombre>parameters. . For example:
  • {LEFT 42} means that the Left key must be pressed 42 times,
  • {h 10} means that the h key must be pressed 10 times.
To specify the operations performed with the mouse, you must use the following codes:
OperationCode
Click with left mouse button{LEFTBTN[,x[,y]]}
Double click with left mouse button{LEFTBTN2[,x[,y]]}
Left mouse button down{LEFTBTN+[,x[,y]]}
Left mouse button up{LEFTBTN-[,x[,y]]}
Click with right mouse button{RIGHTBTN[,x[,y]]}
Double click with right mouse button{RIGHTBTN2[,x[,y]]}
Right mouse button down{RIGHTBTN+[,x[,y]]}
Right mouse button up{RIGHTBTN-[,x[,y]]}
Click with middle mouse button{MIDDLEBTN[,x[,y]]}
Double click with middle mouse button{MIDDLEBTN2[,x[,y]]}
Middle mouse button down{MIDDLEBTN+[,x[,y]]}
Middle mouse button up{MIDDLEBTN-[,x[,y]]}
Mouse movements{MOUSE[,x[,y]]}

x and y are respectively the X-coordinates and the Y-coordinates in relation to the client area of destination window. If x or y is not specified, the value used is 0.

Miscellaneous

  • SendKey cannot send the Print Screen key. to an application.
  • Java SendKey can send the Print Screen key. to an application.
  • In Windows Vista (and later), SendKey does not work properly if the UAC is enabled.
  • The function SendKey function takes into account the current keyboard (modified by the ChangeKeyboard function): the characters sent depend on the keyboard used.
  • SendKey does not work on a non-interactive TSE session.
Componente: wd300std.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Capturando a tela e salvando no banco de dados
Global init project

// Include the "KeyConst.wl" file to manage the keyboard keys
EXTERN "KeyConst.WL"

In Button

Sendkey(“{PTRSC}”)

Clipboard(img_tela_capturada)

Tabela.screen = img_tela_capturada

Tabela.datahora = datesys()+timesys()

Hadd(Tabela)

Compile e teste esses comandos

Vai pressionar a tecla printscreen e salvar no banco a imagem

Precisa que seja compilado para funcionar
Boller
23 08 2023

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local