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);
		}

	}
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章