< 返回版块

kekeimiku 发表于 2022-01-26 23:14

Tags:windows-sys

没什么卵用,图一乐

代码

use windows_sys::Win32::{
    Graphics::Gdi::{BitBlt, GetDC, ReleaseDC, SRCCOPY},
    UI::WindowsAndMessaging::{GetSystemMetrics, SM_CXSCREEN, SM_CYSCREEN},
};

fn main() {
    unsafe {
        let width = GetSystemMetrics(SM_CXSCREEN);
        let height = GetSystemMetrics(SM_CYSCREEN);
        let (mut x, mut y, mut w, mut h);

        loop {
            let hdc = GetDC(0);

            x = fastrand::i32(1..3000) % (width * 5 / 4) - width / 4;
            y = fastrand::i32(1..3000) % (height * 5 / 4) - height / 4;
            w = fastrand::i32(1..3000) % width / 2;
            h = fastrand::i32(1..3000) % height / 2;

            BitBlt(
                hdc,
                x + fastrand::i32(1..3000) % 3 - 1,
                y + fastrand::i32(1..3000) % 5,
                w,
                h,
                hdc,
                x,
                y,
                SRCCOPY,
            );

            ReleaseDC(0,hdc);
        }
    }
}


效果 屏幕截图.png

link: https://github.com/kekeimiku/msrs

评论区

写评论
tokyohuang123 2022-02-09 15:23

Mac路过: 😄

洛佳 2022-02-09 13:57

太乐了,巨硬的系统还能这样玩

soft5 2022-01-27 23:33

停不下来了

sjbwylbs 2022-01-27 10:37

小众需求,可以做更多的内容

c5soft 2022-01-27 09:19

哈哈,好玩,巨硬的力量不可小瞰

Cargo.toml

[dependencies]
windows-sys = { version = "0.30.0", features = [
  "Win32_Foundation",
  "Win32_Graphics_Gdi",
  "Win32_UI_WindowsAndMessaging",
] }
fastrand = "1.7.0"

Neutron3529 2022-01-26 23:21

好活

(可惜我是linux,玩不了)

1 共 6 条评论, 1 页