func (d *VirDomain) SendKey(codeset, holdtime uint, keycodes []uint, flags uint) error { result := C.virDomainSendKey(d.ptr, C.uint(codeset), C.uint(holdtime), (*C.uint)(unsafe.Pointer(&keycodes[0])), C.int(len(keycodes)), C.uint(flags)) if result == -1 { return GetLastError() } return nil }
// SendKey send key(s) to the guest. func (dom Domain) SendKey(codeSet DomainKeycodeSet, hold time.Duration, keycodes []uint32) error { dom.log.Printf("sending keys %v (keycode set = %v) to domain during %v...\n", keycodes, codeSet, time.Duration(hold)) cRet := C.virDomainSendKey(dom.virDomain, C.uint(codeSet), C.uint(hold*time.Millisecond), (*C.uint)(unsafe.Pointer(&keycodes[0])), C.int(len(keycodes)), 0) ret := int32(cRet) if ret == -1 { err := LastError() dom.log.Printf("an error occurred: %v\n", err) return err } dom.log.Println("keys sent") return nil }
func (d *Domain) SendKey(codeset uint, holdtime uint, keycodes []uint, flags uint) error { length := len(keycodes) ckeycodes := make([]C.uint, length) for i, kc := range keycodes { ckeycodes[i] = C.uint(kc) } result := C.virDomainSendKey( d.cptr, C.uint(codeset), C.uint(holdtime), &ckeycodes[0], C.int(length), C.uint(flags), ) if result == -1 { return GetLastError() } return nil }