-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |