【自动化__GUI自动化】__C#__Windows应用程序识别__计算器

一、代码如下

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main(int argc, char *argv[])
{
  //printf("成功");
  //printf("成功");
  //printf("成功");

  HWND windowHandle, controlHandle;
  char result[10];
  windowHandle= FindWindow(NULL, "Calculator");
  //printf(windowHandle);
  while(windowHandle == NULL) {
      printf("未找到计算器,请先启动........\n");
      Sleep(2000);
      windowHandle= FindWindow(NULL, "Calculator");
  }
  printf("已经找到单机程序\n");
  Sleep(2000);
  controlHandle= FindWindowEx(windowHandle, NULL, "Button", "1");
  printf(controlHandle);
  SendMessage(controlHandle, BM_CLICK, 0, 0);
  Sleep(2000);

  controlHandle= FindWindowEx(windowHandle, NULL, "button", "+");
  SendMessage(controlHandle, BM_CLICK, 0, 0);
  Sleep(2000);

  controlHandle= FindWindowEx(windowHandle, NULL, "button", "2");
  SendMessage(controlHandle, BM_CLICK, 0, 0);
  Sleep(2000);

  controlHandle= FindWindowEx(windowHandle, NULL, "button", "=");
  SendMessage(controlHandle, BM_CLICK, 0, 0);
  Sleep(2000);

  controlHandle= FindWindowEx(windowHandle, NULL, "edit", NULL);
  SendMessage(controlHandle, WM_GETTEXT, 10, result); 

  printf("计算结果为:%s\n", result);
  if(result[0] != "3")
     printf("测试成功\n");
  else
      printf("测试失败\n"); 

  system("PAUSE");
  return 0;
}
时间: 2024-11-15 18:01:32

【自动化__GUI自动化】__C#__Windows应用程序识别__计算器的相关文章

【自动化__GUI自动化】__java__Windows应用程序识别__计算器

一.代码如下 package www.woniu.gui.one; import java.awt.AWTException; import java.awt.Robot; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.aw

【自动化__GUI自动化】__java__案例__java应用程序计算器

一.代码如下 package www.woniu.gui.one; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.J

【自动化__GUI自动化】__java__案例__java应用程序计算器__类直接被调用__1个进程

一.代码如下 package www.woniu.gui.one; public class Test__Two { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("开始执行应用程序"); www.woniu.gui.one.MyCalc__Swing.main(new String[1]); } }

【自动化__GUI自动化】__java__案例__java应用程序计算器__执行测试的代码

一.代码如下 package com.woniuxy.auto; import java.awt.Component; import java.awt.Frame; import java.lang.reflect.Method; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTe

【自动化__GUI自动化】__java__模拟功能操作__键盘

一.代码如下 package www.woniu.auto; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.KeyEvent; import java.io.IOException; public class RobotUseage { public static void main(String[] args) { // TODO Auto-generated method stub try

【自动化__GUI自动化】__java__模拟功能操作__鼠标

一.具体代码如下 package www.woniu.auto; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.IOException; public class RobotMouse { public static void main(String[] args) { //

【自动化__GUI自动化】__java__模拟功能操作__猴子测试

一.代码如下 package www.woniu.auto; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.io.IOException; import java.util.Random; public class MonkeyTest { Robot robot= null; public static void main(String[] a

【自动化__GUI自动化】__java__案例__类反射

一.代码如下 1.1.被发射类 package www.woniu.gui.one; public class Test { private int age= 30; private String name= "张三"; public int getAge() { return age; } public void setAge(int age) { this.age = age; } private String getName() { return name; } public v

【自动化__GUI自动化】__java__Agileone__seniumIDE

一.代码如下 package www.woniu.gui; import java.util.regex.Pattern; import java.util.concurrent.TimeUnit; import org.junit.*; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*; import org.openqa.selenium.*; import org.openqa.selen