第一次写博客,呵呵
来源:互联网 发布:c语言定义字符数组长度 编辑:程序博客网 时间:2024/05/17 02:56
传点东西,自动测试的。
class Program
{
[STAThread]
static void Main(string[] args)
{
// Launch the Windows Calculator (calc.exe)
Application application = Application.Launch("calc.exe");
// Get the main and only window
Window window = application.GetWindows()[0];
// Get a reference to the Edit TextBox (AutomationId = "403")
TextBox textBox = (TextBox)window.Get(SearchCriteria.ByAutomationId("403"));
// Get a reference to the RadioButton "Dec" (AutomationId = "307")
RadioButton radioButtonDecimal = window.Get<RadioButton>(SearchCriteria.ByAutomationId("307"));
// If this RadioButton can not be found, the calculator uses the Standard view
// Call the Scientfic/Wetenschappelijk menu to make more options visible
if (radioButtonDecimal == null)
{
// Click on menu View/Beeld (AutomationItem = "Item 2")
window.Get<Menu>(SearchCriteria.ByAutomationId("Item 2")).Click();
// Click on menu Scientific/Wetenschappelijk (AutomationItem = "Item 304")
window.Get<Menu>(SearchCriteria.ByAutomationId("Item 304")).Click();
// The window layout changes. Apparently we need to get the main window
// again to avoid exceptions when searching the buttons
window = application.GetWindows()[0];
}
// Press F6 to make sure we are using the decimal numerical system
window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.F6);
// Focus the Edit TextBox and enter the text 54
textBox.Focus();
Keyboard.Instance.Enter("54");
// Press button "3" (AutomationId = "127") so the value will be 543
window.Get<Button>(SearchCriteria.ByAutomationId("127")).Click();
// Press the "+" button (AutomationId = "92")
window.Get<Button>(SearchCriteria.ByAutomationId("92")).Click();
// Enter the second value. Press button "6" (AutomationId = "130")
window.Get<Button>(SearchCriteria.ByAutomationId("130")).Click();
// Press button "7" (AutomationId = "131")
window.Get<Button>(SearchCriteria.ByText("7")).Click();
// Press the "=" button to calculate the result (AutomationId = "112")
window.Get<Button>(SearchCriteria.ByText("=")).Click();
// Focus the Edit TextBox again and copy the result to the clipboard
// by sending the keyboard combination CTRL+C
textBox.Focus();
Keyboard.Instance.HoldKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL);
Keyboard.Instance.Enter("C");
Keyboard.Instance.LeaveKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL);
// Press F8 to change the numerical system from decimal to binary
window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.F8);
// Show the decimal result via the text on the clipboard
// and the corresponding binary value by accessing the text of the Edit TextBox
Console.WriteLine("543 + 67 = {0} (dec)", System.Windows.Forms.Clipboard.GetText());
Console.WriteLine("{0} (dec) = {1} (bin) ", System.Windows.Forms.Clipboard.GetText(), textBox.Text);
// Close the Calculator application
application.Kill();
Console.ReadKey();
}
}
- 第一次写博客,呵呵
- 第一次写博客 呵呵
- 第一次用writer写博客,挺方便的,呵呵
- 第一次写Blog,呵呵
- 第一次写Blog,呵呵
- 呵呵,第一次写
- 呵呵,开始写博客
- 有点兴奋,第一次写Blog,呵呵~
- 第一次写Blog--:) 呵呵,鼓励一下!!!
- 第一次在linux下写批处理,呵呵
- 第一次写博客
- 第一次写博客
- 第一次写博客
- 第一次写博客
- 第一次写博客
- 我第一次写博客
- 第一次写博客
- 第一次写博客
- Google Chrome Source Code 源码下载
- 如何进行面试薪资谈判
- 最新物理引擎DynaForce准备发布!!! - jiangwei - 博客园
- 超强的as物理引擎(Updated) - 瞠目结舌!
- Attention!-flash 3d物理引擎收录
- 第一次写博客,呵呵
- 旋转卡壳——凸多边形最小面积外接矩形
- com基础
- 汇编语言
- 一天一个C Run-Time Library 函数(2) __max & __min
- 怎样计算任一天是星期几
- Ubuntu 8.10 正式版【官方下载】
- 排序算法java实现
- Unitils配置文件(Unitils介绍四)