我正在尝试使用winapi-rs 0.2.4将this example转换为Rust 1.3。
我有:
fn send_key_event(vk: u16, flags: u32) {
let mut input = winapi::INPUT {
type_: winapi::INPUT_KEYBOARD,
union_: winapi::KEYBDINPUT {
wVk: vk,
wScan: 0,
dwFlags: flags,
time: 0,
dwExtraInfo: 0,
}
};
unsafe {
user32::SendInput(1, &mut input, mem::size_of::<winapi::INPUT>() as i32);
}
}
,不能编译:
error: mismatched types:
expected `winapi::winuser::MOUSEINPUT`,
found `winapi::winuser::KEYBDINPUT`
(expected struct `winapi::winuser::MOUSEINPUT`,
found struct `winapi::winuser::KEYBDINPUT`) [E0308]
Haw我会将键击发送到活动窗口吗?
答案 0 :(得分:2)
您使用的winapi-rs版本中winapi::INPUT
的定义不正确。 It appears to have been fixed today(或昨天,取决于你所在的位置)。