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

Type: System.Int32

The handle of the window.

key

Type: System.Windows.Forms.Keys

The key for send.

keyboardEvent

Type: keyboardEvent

The event of key for emulation.

Glossary Item Box

Sends the keyboard events to the window with specified handle.

Syntax

C# 
public static string SendKey( 
   int handle,
   Keys key,
   KeyboardEvent keyboardEvent
)

Parameters

handle

Type: System.Int32

The handle of the window.

key

Type: System.Windows.Forms.Keys

The key for send.

keyboardEvent

Type: keyboardEvent

The event of key for emulation.

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.

Example

The following code example demonstrates uses of the SendKey method.
C#Copy Code
// find the html element
HtmlElement he = instance.ActiveTab.FindElementByTag("input:text", 0);
// check the element
if (!he.IsVoid)
{
    // send key
    string result = Emulator.SendKey(instance.ActiveTab.Handle,System.Windows.Forms.Keys.Z, KeyboardEvent.Down); 
    // send result
    if (result == "ok" && !Emulator.ErrorDetected) return "Key was sent";
    return "Fail";
}
return "Element not found";
PHPCopy Code
// find the html element
$he = $instance->ActiveTab->FindElementByTag("input:text", 0);
// check the element
if (!$he->IsVoid)
{
    // send key
    $result = ZennoLab\Emulation\Emulator::SendKey($instance->ActiveTab->Handle, System\Windows\Forms\Keys::Z, KeyboardEvent::Down); 
    // send result
    if ($result == "ok" && !ZennoLab\Emulation\Emulator.ErrorDetected) return "Key was sent";
    return "Fail";
}
return "Element not found";

Requirements

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

See Also

© 2013 All Rights Reserved.