ZennoLab Assemblies Documentation
Emulator Class
Members  Example  See Also  Send Feedback
ZennoLab.Emulation Assembly > ZennoLab.Emulation Namespace : Emulator Class

Glossary Item Box

Represents methods for emulation of work with windows.

Syntax

C# 
public class Emulator 

Remarks

In this class represented the methods which can work with windows using the system handle or header (title) of the window.

Example

The following code example demonstrates uses of the some methods of Emulator class.
C#Copy Code
// set active window
string result = Emulator.ActiveWindow("Simple window");
// check result
if (result == "ok" && !Emulator.ErrorDetected)
{
    // send key "z"
    result = Emulator.SendKey("Simple window", 100, 200, System.Windows.Forms.Keys.Z, KeyboardEvent.Press);
    // check result
    if (result == "ok" && !Emulator.ErrorDetected)
    {
        // send text
        result = Emulator.SendText("Simple window",  100, 200, "Simple text", false);
        // check result
        if (result == "ok" && !Emulator.ErrorDetected)
        {
            // mouse move
            Emulator.MouseMove("Simple window",350, 370);
            // mouse click on button as result it will show save file dialog
            result = Emulator.MouseClick("Simple window", MouseButton.Left, MouseButtonEvent.Click, 350, 370);
            // check result
            if (result == "ok" && !Emulator.ErrorDetected)
            {
                // click on button with text "Save"
                return Emulator.ButtonClick("Save as", "Save");
            }
            else return "Fail";
        }
        else return "Fail";
    }
    else return "Fail";
}
else return "Fail";
// close window
result = Emulator.CloseWindow("Simple window");
// check result
if (result != "ok" || Emulator.ErrorDetected) return "Fail";
return "All done";
PHPCopy Code
// set active window
$result = Emulator:ActiveWindow("Simple window");
// check result
if ($result == "ok" && !Emulator::ErrorDetected)
{
    // send key "z"
    $result = Emulator::SendKey("Simple window", 100, 200, System\Windows\Forms\Keys::Z, KeyboardEvent::Press);
    // check result
    if ($result == "ok" && !Emulator::ErrorDetected)
    {
        // send text
        $result = Emulator::SendText("Simple window",  100, 200, "Simple text", false);
        // check result
        if (result == "ok" && !Emulator.ErrorDetected)
        {
            // mouse move
            Emulator::MouseMove("Simple window", 350, 3700);
            // mouse click on button as result it will show save file dialog
            $result = Emulator::MouseClick("Simple window", MouseButton::Left, MouseButtonEvent::Click, 350, 370);
            // check result
            if ($result == "ok" && !Emulator::ErrorDetected)
            {
                // click on button with text "Save"
                return Emulator::ButtonClick("Save as", "Save");
            }
            else return "Fail";
        }
        else return "Fail";
    }
    else return "Fail";
}
else return "Fail";
// close window
$result = Emulator::CloseWindow("Simple window");
// check result
if ($result != "ok" || Emulator::ErrorDetected) return "Fail";
return "All done";

Inheritance Hierarchy

System.Object
   ZennoLab.Emulation.Emulator

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.