Represents methods for emulation of work with windows.
Syntax
Remarks
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"; |
PHP | Copy 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
Requirements
Target Platforms: Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also