Oracle Forms Francois Degrelle

How to simulate a key pressed



Home page



The purpose is to simulate keyboard key pressing in a Forms application.


Sometimes, you need to simulate a keyboard action at runtime, for instance go to the end of the text in a Text Item, to add information or simply to put the cursor at the end.

The d2kwutil library offers a function dedicated to this purpose : win_api_shell.sendkeys()



Syntax

PROCEDURE Win_Api_Shell.SendKeys

(hWnd IN PLS_INTEGER,

Keys IN VARCHAR2,

RaiseExceptions IN BOOLEAN DEFAULT FALSE);



Parameters

Target

The Window handle of the window you want to send the keystrokes to. You can get this handle by using the GET_WINDOW_PROPERTY built-in.

Keystrokes

The keystrokes that you want to send to the window. Use these characters for modifier keys:

Shift = +;
Control = ^;
Alt = %.

Modifiers can be Escaped by enclosing them in braces {}.

To apply the modifiers to a sequence of keys, enclose the keys in brackets, as in "^(abc)". Other special keys are enclosed in braces thus:



{Backspace}
{Break}
{CapsLock}
{Clear}
{Delete}
{End}
{Enter}
{Esc}
{Help}
{Home}
{Insert}
{NumLock}
{PgDown}
{PgUp}
{PrtSc}
{ScrollLock}
{Tab}
{F1} - {F12}
{Up}
{Down}
{Left}
{Right}


RaiseExceptions If TRUE, then if the procedure fails to send or parse the keystrokes, the explicit PL/SQL exception NO_DATA_FOUND will be raised

 

Examples:

win_api_shell.sendkeys(get_window_property('WINDOW1',window_handle),'{End}',TRUE);

win_api_shell.sendkeys(get_window_property('WINDOW1',window_handle),'%(ae)',TRUE);





D2KWUTIL download and install


I am not sure that d2kwutil is still reachable from the OTN Forms page, but you can download it here.