當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Browser.GetRootWindowHandle方法代碼示例

本文整理匯總了Golang中github.com/nvsoft/cef.Browser.GetRootWindowHandle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Browser.GetRootWindowHandle方法的具體用法?Golang Browser.GetRootWindowHandle怎麽用?Golang Browser.GetRootWindowHandle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/nvsoft/cef.Browser的用法示例。


在下文中一共展示了Browser.GetRootWindowHandle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: win_start_browser

func win_start_browser(browser *cef.Browser, message *cef.CefProcessMessage) interface{} {
	fmt.Printf("win_start_browser\n")
	handle := browser.GetWindowHandle()
	openerHandle := browser.GetOpenerWindowHandle()
	rootHandle := browser.GetRootWindowHandle()
	fmt.Printf("win_start_browser handle=%v openerHandle=%v rootHandle=%v\n", handle, openerHandle, rootHandle)
	win.ShowWindow(win.HWND(rootHandle), win.SW_MAXIMIZE)
	return 0
}
開發者ID:CodyGuo,項目名稱:gapp,代碼行數:9,代碼來源:callbacks.go

示例2: win_emuClick

// 模擬點擊
func win_emuClick(browser *cef.Browser, message *cef.CefProcessMessage) interface{} {
	fmt.Printf("win_emuClick\n")
	handle := browser.GetWindowHandle()
	openerHandle := browser.GetOpenerWindowHandle()
	rootHandle := browser.GetRootWindowHandle()
	fmt.Printf("win_start_browser handle=%v openerHandle=%v rootHandle=%v\n", handle, openerHandle, rootHandle)
	//win.ShowWindow(win.HWND(rootHandle), win.SW_MAXIMIZE)
	// 模擬點擊
	// 查找窗口
	url := message.GetArgumentList().GetString(1)
	fmt.Printf("url=%v\n", url)
	w, ok := windowHolders[url]
	if ok {
		fmt.Printf("找到窗口\n")
		b, o := cef.BrowserByHandle(unsafe.Pointer(w))
		if o {
			x := message.GetArgumentList().GetInt(2)
			y := message.GetArgumentList().GetInt(3)
			buttonType := message.GetArgumentList().GetBool(4)
			fmt.Printf("X=%v Y=%v ButtonType=%v\n", x, y, buttonType)
			rootHandle = b.GetRootWindowHandle()
			//win.ShowWindow(win.HWND(rootHandle), win.SW_MAXIMIZE)
			// 模擬鼠標
			var pt win.POINT
			pt.X = int32(x) // This is your click coordinates
			pt.Y = int32(y)

			hWnd := win.HWND(rootHandle)

			go func() {
				win.SetForegroundWindow(hWnd)
				time.Sleep(3 * time.Second)

				win.ClientToScreen(hWnd, &pt)

				fmt.Printf("ClientToScreen X=%v Y=%v\n", pt.X, pt.Y)

				cx_screen := win.GetSystemMetrics(win.SM_CXSCREEN) //屏幕 寬
				cy_screen := win.GetSystemMetrics(win.SM_CYSCREEN) //     高

				real_x := 65535 * pt.X / cx_screen //轉換後的 x
				real_y := 65535 * pt.Y / cy_screen //         y

				var input win.MOUSE_INPUT
				input.Type = win.INPUT_MOUSE
				input.Mi.Dx = real_x
				input.Mi.Dy = real_y
				if buttonType {
					input.Mi.DwFlags = (win.MOUSEEVENTF_ABSOLUTE | win.MOUSEEVENTF_MOVE | win.MOUSEEVENTF_RIGHTDOWN | win.MOUSEEVENTF_RIGHTUP)
				} else {
					input.Mi.DwFlags = (win.MOUSEEVENTF_ABSOLUTE | win.MOUSEEVENTF_MOVE | win.MOUSEEVENTF_LEFTDOWN | win.MOUSEEVENTF_LEFTUP)
				}
				input.Mi.MouseData = 0
				input.Mi.DwExtraInfo = 0
				input.Mi.Time = 0
				win.SendInput(2, unsafe.Pointer(&input), int32(unsafe.Sizeof(input)))

				fmt.Printf("點擊")
			}()
			//hWnd = win.WindowFromPoint(pt)
		}
	} else {
		fmt.Printf("找不到窗口\n")
	}
	return 0
}
開發者ID:CodyGuo,項目名稱:gapp,代碼行數:67,代碼來源:callbacks.go

示例3: win_emuInput

// 模擬輸入
func win_emuInput(browser *cef.Browser, message *cef.CefProcessMessage) interface{} {
	rootHandle := browser.GetRootWindowHandle()
	url := message.GetArgumentList().GetString(1)
	fmt.Printf("url=%v\n", url)
	w, ok := windowHolders[url]
	if ok {
		fmt.Printf("找到窗口\n")
		b, o := cef.BrowserByHandle(unsafe.Pointer(w))
		if o {
			inputText := message.GetArgumentList().GetString(2)
			fmt.Printf("inputText=%v\n", inputText)
			rootHandle = b.GetRootWindowHandle()
			//win.ShowWindow(win.HWND(rootHandle), win.SW_MAXIMIZE)
			// 模擬鼠標
			var pt win.POINT
			pt.X = int32(0) // This is your click coordinates
			pt.Y = int32(0)

			hWnd := win.HWND(rootHandle)

			go func() {
				win.SetForegroundWindow(hWnd)
				time.Sleep(5 * time.Second)

				win.ClientToScreen(hWnd, &pt)

				fmt.Printf("ClientToScreen X=%v Y=%v\n", pt.X, pt.Y)

				//sendinput.SendString(inputText)

				ss := strings.Split(inputText, "")
				for i := 0; i < len(ss); i++ {
					c := ss[i]
					cc := []rune(c)[0]
					keyCode := *syscall.StringToUTF16Ptr(c)
					shift := false
					if cc >= 'a' && cc <= 'z' {
						fmt.Printf("小寫\n")
						c = strings.ToUpper(c)
						keyCode = *syscall.StringToUTF16Ptr(c)
					}
					if cc >= 'A' && cc <= 'Z' {
						fmt.Printf("大寫\n")
						shift = true
					}
					index := strings.Index(spec_chars, c)
					if index >= 0 {
						fmt.Printf("特殊字符1 c=%v index=%v\n", c, index)
						ss := strings.Split(base_chars, "")
						fmt.Printf("ss=%v\n", ss)
						c = ss[index]
						fmt.Printf("特殊字符2 c=%v\n", c)
						keyCode = *syscall.StringToUTF16Ptr(c)
						shift = true
					}
					switch {
					case c == ";":
						keyCode = win.VK_OEM_1
					case c == ":":
						keyCode = win.VK_OEM_1
						shift = true
					case c == "=":
						keyCode = win.VK_OEM_PLUS
					case c == "+":
						keyCode = win.VK_OEM_PLUS
						shift = true
					case c == "-":
						keyCode = win.VK_OEM_MINUS
					case c == "_":
						keyCode = win.VK_OEM_MINUS
						shift = true
					case c == ",":
						keyCode = win.VK_OEM_COMMA
					case c == "<":
						keyCode = win.VK_OEM_COMMA
						shift = true
					case c == ".":
						keyCode = win.VK_OEM_PERIOD
					case c == ">":
						keyCode = win.VK_OEM_PERIOD
						shift = true
					case c == "/":
						keyCode = win.VK_OEM_2
					case c == "?":
						keyCode = win.VK_OEM_2
						shift = true
					case c == "`":
						keyCode = win.VK_OEM_3
					case c == "~":
						keyCode = win.VK_OEM_3
						shift = true
					case c == "[":
						keyCode = win.VK_OEM_4
					case c == "{":
						keyCode = win.VK_OEM_4
						shift = true
					case c == `\`:
						keyCode = win.VK_OEM_5
					case c == "|":
//.........這裏部分代碼省略.........
開發者ID:CodyGuo,項目名稱:gapp,代碼行數:101,代碼來源:callbacks.go


注:本文中的github.com/nvsoft/cef.Browser.GetRootWindowHandle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。