How Do I Simulate a Keystroke? (Magic xpa 4.x)
There are two ways to simulate a keystroke in Magic xpa, using a KBPut() function, or using a Raise Event operation. KBPut() is a more generic function, and it allows you to insert characters and create long macro streams. Raise Event, on the other hand, allows you more flexibility, since you can not only simulate keyboard events, you can also raise other kinds of events.
Here we will cover the KBPut() function.
|
|
Before
|
After
|
The syntax of the KBPut() function is:
KBPut(String)
Where String is a string of formatted characters as shown below. The concatenation operator (&) is used to attach them all together.
KBPut Characters
What
|
Syntax
|
Example
|
Quick way to enter them
|
Letters, Numbers
|
Enter text in quotes
|
‘123.2’
|
|
Keystrokes
|
name followed by KBD
|
‘Tab’KBD
|
Select them from the Shortcut right-click menu
|
Events
|
name followed by EVENT
|
‘Next Field’EVENT
|
Select them from the Internal Events right-click menu
|
You can see that ‘Tab’KBD and ‘Next Field’EVENT are basically equivalent in this case. It is usually safer to use the EVENT coding, because the keyboard may be remapped.
Note: KBPut() only works in a window that is pure Magic xpa. It does not affect called Windows dialogs.
How Do I Work with the Magic xpa Engine as an Event-Driven Engine?
The Online Samples project (program EL06)