Skip to content

Commit

Permalink
Upload initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
Naamloos committed Nov 23, 2021
1 parent 1b06052 commit 2aefd77
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'win_11_start_spacer'",
"cargo": {
"args": [
"build",
"--bin=win_11_start_spacer",
"--package=win_11_start_spacer"
],
"filter": {
"name": "win_11_start_spacer",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'win_11_start_spacer'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=win_11_start_spacer",
"--package=win_11_start_spacer"
],
"filter": {
"name": "win_11_start_spacer",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "win_11_start_spacer"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
winapi = { version = "0.3", features = ["winuser"] }
32 changes: 32 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::mem::zeroed;
use std::ffi::CString;

use winapi::shared::windef::HWND;
use winapi::um::winuser;

fn main()
{
println!("Let's fix what Microsoft couldn't!");

// define strings for the class name and window name for the start menu
let class_name : CString = CString::new("Windows.UI.Core.CoreWindow").expect("Whope");
let window_name : CString = CString::new("Start").expect("Whope");

unsafe
{
// Grab the window handle to the start menu
let wnd : HWND = winuser::FindWindowA(class_name.as_ptr(), window_name.as_ptr());

// initialize the DEVMODEA struct. For sonme reason, default still does not work.
let mut dev_mode = zeroed();
// Get the current main monitor settings (same monitor start should display on).
winuser::EnumDisplaySettingsA(std::ptr::null(), winuser::ENUM_CURRENT_SETTINGS, &mut dev_mode);

// Calculate proper x position and move start menu
let x_pos = ((dev_mode.dmPelsWidth / 2) - (666 / 2)) as i32;
winuser::SetWindowPos(wnd, winuser::HWND_TOPMOST, x_pos, 48, 666, 750, 0);
// Start menu is 666 by 750 pixels (including the padding which is part of the actual window)

println!("Moved start menu to x:{} y:48", x_pos);
}
}

0 comments on commit 2aefd77

Please sign in to comment.