ZennoLab Assemblies Documentation
SendKey(String,Int32,Int32,Keys,KeyboardEvent,Boolean) Method
See Also  Example Send Feedback
ZennoLab.Emulation Assembly > ZennoLab.Emulation Namespace > Emulator Class > SendKey Method : SendKey(String,Int32,Int32,Keys,KeyboardEvent,Boolean) Method
windowName

Type: System.String

The header of the window.

x

Type: System.Int32

The x coordinate relative to the window.

y

Type: System.Int32

The y coordinate relative to the window.

key

Type: System.Windows.Forms.Keys

The key for send.

keyboardEvent

Type: keyboardEvent

The event of key for emulation.

topMost

Type: System.Boolean

true if need to show the window on top of all; otherwise, false. Default value is false.

Glossary Item Box

Sends the keyboard events to the specified window.

Syntax

C# 
public static string SendKey( 
   string windowName,
   int x,
   int y,
   Keys key,
   KeyboardEvent keyboardEvent,
   bool topMost
)

Parameters

windowName

Type: System.String

The header of the window.

x

Type: System.Int32

The x coordinate relative to the window.

y

Type: System.Int32

The y coordinate relative to the window.

key

Type: System.Windows.Forms.Keys

The key for send.

keyboardEvent

Type: keyboardEvent

The event of key for emulation.

topMost

Type: System.Boolean

true if need to show the window on top of all; otherwise, false. Default value is false.

Return Value

Type: System.String

The answer with information about the success of the current command's execution. If current command was successful then this answer is "ok"; otherwise message describing the error.

Remarks

There are several ways of calling this method. The parameter topMost have the default value and you can call the method without this parameter.

The x and y can be -1. In this case the key will be sent to the current window.

Example

The following code example demonstrates uses of the SendKey method.
C#Copy Code
// send the key "a"
string result = Emulator.SendKey("Window", 200, 200, System.Windows.Forms.Keys.A, KeyboardEvent.Press);
// check result
if (result == "ok" && !Emulator.ErrorDetected) return "Key was sent";
else return "Fail";
PHPCopy Code
// send the key "a"
$result = ZennoLab\Emulation\Emulator::SendKey("Window", 200, 200, System\Windows\Forms\Keys.A, KeyboardEvent::Press);
// check result
if ($result == "ok" && !ZennoLab\Emulation\Emulator::ErrorDetected) return "Key was sent";
else return "Fail";

Requirements

Target Platforms: Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2014 All Rights Reserved.