本文整理匯總了Golang中github.com/nvsoft/cef.Browser.GetWindowHandle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Browser.GetWindowHandle方法的具體用法?Golang Browser.GetWindowHandle怎麽用?Golang Browser.GetWindowHandle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nvsoft/cef.Browser
的用法示例。
在下文中一共展示了Browser.GetWindowHandle方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: win_handler_sizeTo
// 為窗口設置新的尺寸
func win_handler_sizeTo(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
fmt.Println("win_handler_sizeTo")
width := cef.V8ValueToInt32(args[0])
height := cef.V8ValueToInt32(args[1])
h := win.HWND(browser.GetWindowHandle())
var rect win.RECT
win.GetWindowRect(h, &rect)
fmt.Printf("win_handler_sizeTo Left=%v,Right=%v,Width=%v,Height=%v\n", rect.Left, rect.Top, width, height)
win.MoveWindow(h, rect.Left, rect.Top, width, height, true)
//result = 1
return
}
示例2: win_handler_restore
// 恢複窗口
func win_handler_restore(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
fmt.Println("win_handler_restore")
h := win.HWND(browser.GetWindowHandle())
win.ShowWindow(h, win.SW_RESTORE)
return
}
示例3: win_handler_maximize
// 最大化窗口
func win_handler_maximize(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
fmt.Println("win_handler_maximize")
h := win.HWND(browser.GetWindowHandle())
win.ShowWindow(h, win.SW_MAXIMIZE)
return
}
示例4: win_handler_quit
// 退出程序
func win_handler_quit(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
h := win.HWND(browser.GetWindowHandle())
win.SendMessage(h, win.WM_CLOSE, 0, 0)
//win.PostQuitMessage(0);
os.Exit(1)
return
}
示例5: win_handler_setTitle
// 為窗口設置標題
func win_handler_setTitle(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
title := cef.V8ValueToString(args[0])
h := win.HWND(browser.GetWindowHandle())
win.SetWindowText(h, title)
return
}
示例6: 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
}
示例7: win_handler_startDrag
// 移動窗口
func win_handler_startDrag(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
fmt.Println("win_handler_startDrag")
h := win.HWND(browser.GetWindowHandle())
var pt win.POINT
win.GetCursorPos(&pt)
isDrag = true
win.PostMessage(h, win.WM_LBUTTONDOWN, win.HTCAPTION, uintptr(win.MAKELONG(uint16(pt.X), uint16(pt.Y))))
return
}
示例8: win_handler_moveTo
// 為窗口設置新的位置
func win_handler_moveTo(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
fmt.Println("win_handler_moveTo")
left := cef.V8ValueToInt32(args[0])
top := cef.V8ValueToInt32(args[1])
fmt.Printf("win_handler_moveTo left=%v,top=%v\n", left, top)
h := win.HWND(browser.GetWindowHandle())
var rect win.RECT
win.GetWindowRect(h, &rect)
width := int32(rect.Right - rect.Left)
height := int32(rect.Bottom - rect.Top)
fmt.Printf("win_handler_moveTo Left=%v,Right=%v,Width=%v,Height=%v\n", left, top, width, height)
win.MoveWindow(h, left, top, width, height, true)
return
}
示例9: win_handler_close
// 關閉窗口
func win_handler_close(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
h := win.HWND(browser.GetWindowHandle())
win.SendMessage(h, win.WM_CLOSE, 0, 0)
return
}
示例10: 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
}
示例11: emuInput2
func emuInput2(browser *cef.Browser) {
fmt.Printf("emuInput\n")
// 查找
frame := browser.GetMainFrame()
//frameCount := browser.GetFrameCount()
//fmt.Printf("frameCount=%v\n", frameCount)
//frameIdentifiers := browser.GetFrameIdentifiers()
//fmt.Printf("frameIdentifiers=%v\n", frameIdentifiers)
// 計算frame坐標
//mainFrame := browser.GetMainFrame()
//login_frame_left, login_frame_top := navigator.GetHtmlElementOffset(mainFrame, "#loginIframe")
//fmt.Printf("#loginIframe坐標:left=%v,top=%v\n", login_frame_left, login_frame_top)
// 獲取frameElement id
//for i := 0; i < len(frameIdentifiers); i++ {
//identifier := frameIdentifiers[i]
//fmt.Printf("frame-identifier=%v\n", identifier)
// id=loginIframe
//frame := browser.GetFrameByIdent(identifier)
//if !frame.IsValid() {
// fmt.Printf("IsValid fail.\n")
// continue
//}
/*c := `
var id_ = "";
var frame = window.frameElement; //Get <iframe> element of the window
if (frame) {
//if (typeof frameElement_.id !== "undefined" && frameElement_.id !== null) {
// some code here
if (typeof frame.id !== "undefined" && frame.id !== null) {
id_ = frame.id;
}
}
app.cefResult(id_);
`*/
//frame_id := frame.ExecuteJavaScriptWithResult(c)
//fmt.Printf("frame_id=%v\n", frame_id)
//if frame_id == "loginIframe" {
fmt.Printf("找到登錄界麵")
navigator.InjectFocus(browser, true)
fmt.Printf("開始登錄支付寶...\n")
fmt.Printf("獲取賬號輸入框按鈕坐標\n")
left, top := navigator.GetHtmlElementOffset(frame, "#J-input-user")
fmt.Printf("輸入框坐標:left=%v,top=%v\n", left, top)
x := left + 10
y := top + 10
fmt.Printf("點擊賬號輸入框 x=%v,y=%v\n", x, y)
hWnd := win.HWND(browser.GetWindowHandle())
fmt.Printf("hWnd=%v\n", hWnd)
navigator.MouseClick(hWnd, x, y)
fmt.Printf("點擊賬號輸入框\n")
time.Sleep(2 * time.Second)
navigator.InjectKeyPress(browser, "[email protected]")
fmt.Printf("輸入完成.\n")
time.Sleep(5 * time.Second)
fmt.Printf("點擊密碼輸入框\n")
left, top = navigator.GetHtmlElementOffset(frame, "#password_input")
x = left + 10 + 40
y = top + 10
fmt.Printf("輸入框坐標:left=%v,top=%v\n", x, y)
navigator.InjectMouseClick(browser, x, y)
fmt.Printf("點擊賬號輸入框\n")
time.Sleep(3 * time.Second)
navigator.InjectKeyPress(browser, "1")
fmt.Printf("輸入完成.\n")
time.Sleep(5 * time.Second)
fmt.Printf("失去焦點1.\n")
navigator.InjectFocus(browser, false)
fmt.Printf("失去焦點2.\n")
//}
//}
}