selenium测试用JNAUtils3

// 点击窗口window内的item按钮控件
	public static void clickItem(String window, String item) {
		HWND hwnd = JNAUtils.getUnitFrameWnd(window);
		if (hwnd != null) {
			List<HWND> items = JNAUtils.getItems(hwnd);
			for (HWND temp : items) {
				String name = JNAUtils.getTitle(temp);
				if (name.equals(item)) {
					// System.out.println(name);
					RECT rc = JNAUtils.getWindowRect(temp);
					int x = (rc.left + rc.right) / 2;
					int y = (rc.top + rc.bottom) / 2;
					JNAUtils.setFocus(hwnd);
					RobotUtils.click(x, y);
					RobotUtils.click(x, y);
				}
				// System.out.println(name);
			}
		}
	}
public static void main(String arg[]) {
		// RobotUtils.winRun();
		// RobotUtils.pressKeyByStr("notepad 1.txt");
		// RobotUtils.submit();
		// listTitles();
		HWND hwnd = getUnitFrameWnd("资料");
		// HWND hwnd = gethwnd();
		if (hwnd != null) {
			System.out.println(hwnd);
			System.out.println("test");
			RECT rf = getWindowRect(hwnd);
			System.out.println(rf.left + "," + rf.right + "," + rf.top + ","
					+ rf.bottom);
			setFocus(hwnd);
			System.out.println("test");
			// RobotUtils.pressKeyByStr("hahaha");
			rf = getWindowRect(hwnd);
			System.out.println(rf.left + "," + rf.right + "," + rf.top + ","
					+ rf.bottom);
			// listItems(hwnd);
			hwnd = getACtiveHwnd();
			System.out.println(hwnd);
			System.out.println("test");
			setFocus(hwnd);
			System.out.println("test");
			String title = getTitle(hwnd);
			System.out.println(title);
		}

	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值